I have a piece of code like this:
printf "%.s " $(seq 1 $count)
It actually belongs to an else condition and its job is to print out whitespaces $count times..
It works fine if I enter a string like this:
printf "%.shelloworld " $(seq 1 $count)
but not when i just put in whitespaces.
Any work arounds?
Works for me:
# printf "%.s " $(seq 1 10) | hexdump -C
00000000 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | |
00000010 20 20 20 20 | |
Is this the exact command that's being entered, or is there other variable substitution happening? Because the exact thing you seem to be experiencing would happen if you didn't quote a particular variable expansion:
# frm="%.s "; printf $frm $(seq 1 10) | hexdump -C
[no output]
Whereas:
# frm="%.s "; printf "$frm" $(seq 1 10) | hexdump -C
00000000 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | |
00000010 20 20 20 20 | |
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.