1. Computing & Technology
7.1 Linux Advanced Text Processing Tools
Learn advanced Linux commands
 
 Related Resources
• Linux Newbie Administrator Guide
• 0. Linux Benefit
• 1. Before Installation
• 2. Linux Resources/Help
• 3. Basic Operations FAQ
• 4. Newbie Admin FAQ
• ~ 4.1 Lilo
• ~ 4.2 Drives
• ~ 4.3 X-Windows
• ~ 4.4 Configurations
• ~ 4.5 Networking
5. Shortcuts / Commands
• 6. Linux Applications
• 7. Learn Linux Commands
• A. How to Upgrade Kernel?
 

od

(=octal dump). Display contents as octal numbers. This can be useful when the output contains non-printable characters. For example, a filename may contain non-printable characters and be a real pain. This can also be handy to view binary files.

Examples:
dir | od -c | more

(I would probably rather do: ls -b to see any non-printable characters in filenames).

cat my_file | od -c |more
od my_file |more

Comparison of different outputs:
Show 16 first characters from a binary (/bin/sh) as ASCII characters or backslash escapes (octal):
od -N 16 -c /bin/sh
output:
0000000 177   E   L   F 001 001 001  \0  \0  \0  \0  \0  \0  \0  \0  \0
Show the same binary as named ASCII characters:
od -N 16 -a /bin/sh
output:
0000000 del   E   L   F soh soh soh nul nul nul nul nul nul nul nul nul
Show the same binary as short hexcadecimals:
od -N 16 -t x1 /bin/sh
output:
0000000 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Show the same binary as octal numbers:
od -N 16 /bin/sh
output:
0000000 042577 043114 000401 000001 000000 000000 000000 000000

Next > Back to "Learn Linux Commands"

Can't find what you are looking for?
Search the

Stay up-to-date!
Subscribe to the Linux free newsletter.

Discuss in my forum

©2012 About.com. All rights reserved.

A part of The New York Times Company.