Bash/Printf
Aus SchnallIchNet
< Bash
Version vom 24. April 2013, 06:20 Uhr von Cbs (Diskussion | Beiträge) (hat „Printf“ nach „Bash/Printf“ verschoben)
repeated output
if you want to format output e.g. by spaces do
printf "%10s" " "
this will produce a 10 bytes long string of ' ' (spaces).
if you want to have anything else than spaces use tr
printf "%10s" " " | tr ' ' '#' ##########
this is because non-given strings are interpretes as NULL-string
so the following does NOT work:
printf "%10s" "#" #
printf expects a 10-byte long string because of the %10s format string.
because it only gets 1 byte. it prints out 9 bytes spaces and only ONE '#'
this is the reason you will have to use tr