Reputation: 99
Im trying to print like below
2333 k4k3 34kk 34r4
233k 2344 234l llll
with command
printf "%04d \n" "1111" "1123" "3333" "3333"
but its breaks it. what I want to happen is all 4 values will be in single line and then add new line again.
Upvotes: 3
Views: 3321
Reputation: 85800
The C style printf
in bash
expects each format specifier and an associated argument to be provided. For example
printf "Surname: %s Name: %s\n" "foo" "bar"
So you need to provide the specifiers for each of the arguments needed, something like
printf "%04d %04d %04d %04d\n" "1111" "1123" "3333" "3333"
(or) if you want to treat the entire set of words as a single string literal, you just need to use a single string format specifier. Notice below the quotes covering the entire set of arguments as one.
printf "%s \n" "1111 1123 3333 3333"
See The printf command in bash for more options and help articles.
Upvotes: 1