Name

od [man page] - dump files in octal and other formats

Synopsis

od [OPTION]... [FILE]...
od [-abcdfilosx]... [FILE] [[+]OFFSET[.][b]]
od --traditional [OPTION]... [FILE] [[+]OFFSET[.][b] 
   [+][LABEL][.][b]] 

Frequently used options

t, --format=TYPE
      select output format or formats
-a    same as -t a,  select named characters
-c    same as -t c,  select ASCII characters or
      backslash escapes
-x    same as -t x2, select hexadecimal 2-byte 
      units
-l    same as -t dL, select decimal longs

Examples

Suppose that we have a file which contains:

$ echo -e "one\ntwo\nthree\nfour\nfive\n\nsix" > file 

od - create sample file
by default all output from od command comes as octal:

$ od file 

od - octal output
First column is a octal offset of a file and the following output is a file content in octal representation.With -c option we can instruct od command to represent values in a file as ASCII.

$ od -a file 

od - ASCII output:[[Image:od02.gif]] To get understanding of what a offset is, we can use wc command to get total number of bytes in the file and that convert it with bc to octal number.

$ wc -c file
$ echo "obase=8; ibase=10; 29;" | bc

od - bc to octal number

ARE YOU LOOKING FOR A LINUX JOB?
Submit your RESUME, create a JOB ALERT or subscribe to RSS feed on LinuxCareers.com.
DO YOU NEED ADDITIONAL HELP?
Get extra help by visiting our LINUX FORUM or simply use comments below.

You may also be interested in: