odコマンド

Linux上ではテキストファイルがどのように扱われるのか気になったので調べてみる。

 

odコマンドとやらでファイルがバイナリ表示できるようだ。

-xで16進表示。

-cでアスキー表示。

[shin@cent6-5 helloworld]$ od helloworld.c -x
0000000 6923 636e 756c 6564 3c20 7473 6964 2e6f
0000020 3e68 0a0a 6f76 6469 6d20 6961 286e 7b29
0000040 200a 7020 6972 746e 2866 6822 6c65 6f6c
0000060 7720 726f 646c 2221 3b29 7d0a 000a
0000075
[shin@cent6-5 helloworld]$ od helloworld.c -c
0000000   #   i   n   c   l   u   d   e       <   s   t   d   i   o   .
0000020   h   >  \n  \n   v   o   i   d       m   a   i   n   (   )   {
0000040  \n           p   r   i   n   t   f   (   "   h   e   l   l   o
0000060       w   o   r   l   d   !   "   )   ;  \n   }  \n
0000075