OD Command Usage Examples

by Ramesh

od command dumps a file in octal, decimal, and other formats.

Use OD on a text file

The following sample text file is used in the examples below.

$ cat sample-file.txt 

abc 	de
f     h

Option –b and –c are typical usages as shown below.

  • -b is same as option -t oC, select octal bytes
  • -c is same as option -t c, select ASCII characters or backslash escapes
# od -c special-chars.txt 

0000000   a   b   c      \t   d   e  \n   f                      \t   h
0000020  \n
0000021

# od -bc special-chars.txt 

0000000 141 142 143 040 011 144 145 012 146 040 040 040 040 040 011 150
          a   b   c      \t   d   e  \n   f                      \t   h
0000020 012
         \n
0000021

Use OD on a binary file

Read the first 16 bytes and display equivalent ASCII characters or backslash:

# od -N16 -c /usr/bin/h2xs 

0000000   #   !   /   u   s   r   /   b   i   n   /   p   e   r   l  \n
0000020

Read the first 16 bytes and display equivalent names characters:

# od -N16 -a /usr/bin/h2xs 

0000000   #   !   /   u   s   r   /   b   i   n   /   p   e   r   l  nl
0000020

Read the first 16 bytes and display octal bytes:

# od -N16 -bc /usr/bin/h2xs 

0000000 043 041 057 165 163 162 057 142 151 156 057 160 145 162 154 012
          #   !   /   u   s   r   /   b   i   n   /   p   e   r   l  \n
0000020
1 onzepattes September 24, 2013 at 2:49 pm

thnks a lot for this informations

Comments on this entry are closed.

{ 2 trackbacks }

Previous post:

Next post: