Printf notes: Difference between revisions
From Federal Burro of Information
Jump to navigationJump to search
(Created page with " hex: <pre> mitsor-bpe01:/etc # printf "%.8x\n" 13 0000000d mitsor-bpe01:/etc # printf "%.8x\n" 14 0000000e mitsor-bpe01:/etc # printf "%.8x\n" 15 0000000f mitsor-bpe01:/etc ...") |
No edit summary |
||
Line 12: | Line 12: | ||
00000010 | 00000010 | ||
mitsor-bpe01:/etc # | mitsor-bpe01:/etc # | ||
</pre> | |||
binary: (print f can't do this) | |||
<pre> | |||
#NOTE: Using bc command you can directly get output at command line. | |||
# $ echo 'obase=2;15' | bc | |||
# 1111 | |||
# $ echo 'obase=2;1023' | bc | |||
# 1111111111 | |||
# $ echo 'obase=2;1024' | bc | |||
# 10000000000 | |||
# No need of ibase=10, because default ibase is 10. | |||
</pre> | </pre> | ||
Revision as of 16:07, 10 May 2013
hex:
mitsor-bpe01:/etc # printf "%.8x\n" 13 0000000d mitsor-bpe01:/etc # printf "%.8x\n" 14 0000000e mitsor-bpe01:/etc # printf "%.8x\n" 15 0000000f mitsor-bpe01:/etc # printf "%.8x\n" 16 00000010 mitsor-bpe01:/etc #
binary: (print f can't do this)
#NOTE: Using bc command you can directly get output at command line. # $ echo 'obase=2;15' | bc # 1111 # $ echo 'obase=2;1023' | bc # 1111111111 # $ echo 'obase=2;1024' | bc # 10000000000 # No need of ibase=10, because default ibase is 10.