Difference between revisions of "Printf formatting"
From thelinuxwiki
(Pushed from thelinuxwiki.com.) |
|||
Line 2: | Line 2: | ||
http://wiki.bash-hackers.org/commands/builtin/printf | http://wiki.bash-hackers.org/commands/builtin/printf | ||
+ | |||
+ | $ printf "%10s%10s\n" "foo" "bar" | ||
+ | foo bar | ||
+ | |||
+ | $ printf "%-10s%10s\n" "foo" "bar" | ||
+ | foo bar | ||
+ | |||
+ | $ printf "%10s%-10s\n" "foo" "bar" | ||
+ | foobar | ||
+ | |||
+ | $ printf "%-10s%-10s\n" "foo" "bar" | ||
+ | foo bar | ||
+ | |||
+ | |||
[[category:bash]] | [[category:bash]] |
Revision as of 20:14, 31 October 2013
just go here...
http://wiki.bash-hackers.org/commands/builtin/printf
$ printf "%10s%10s\n" "foo" "bar" foo bar
$ printf "%-10s%10s\n" "foo" "bar" foo bar
$ printf "%10s%-10s\n" "foo" "bar" foobar
$ printf "%-10s%-10s\n" "foo" "bar" foo bar