LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-15-2006, 06:58 AM   #1
rs_vijay
Member
 
Registered: Aug 2006
Location: Allahabad,India
Distribution: Fedora Core 5
Posts: 41

Rep: Reputation: 15
what does this "od" i.e octal dump exactly mean??


I have just started studying UNIX frm Kernighan & Pike.Things are better graspable until I encountered this "od" command which he says is for octal dump.

I tried to understand this from the man page but in vain.Again thinking that experimenting comes to the rescue,i just wanted to match standard input with the output ,
so first I tried
"aaaa
^d " n the output was
0000000 060541 060541 000012
0000005 something as five strings against 4 chars

next "aaaaaaaaa
^d " n this time
0000000 060541 060541 060541 060541 005141
0000012
7 strings against 9 chars

next " aaaaa
aaaa
aaa
^d " n this time
0000000 060541 060541 005141 060541 060541 060412 060541 000012
0000017 10 strings against 12+3 chars


so there i struck,found two things in common the first one in each case is " 0000000 " of these three trails and second is each pattern consists of either 6 or 7 digits..
culdn't make anything more.....

hope i am pretty clear abt my problem so can u plz help me....
thnx for the same!!
 
Old 12-15-2006, 08:37 AM   #2
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
The key is to the type modifier that od is using. By default od uses a parameter something like this:
Code:
   od -t oS
Looking at the man page, it tells us:
Quote:
o[SIZE]
octal, SIZE bytes per integer

SIZE is a number. For TYPE in doux, SIZE may also be C for sizeof(char), S for sizeof(short),
<snip>
Since the SIZE is a short, each two groups of characters in your example are being interpreted as a single octal number in the output, since the sizeof(short) on your Linux system is 2. If you'd like to see a 1-1 mapping between the output choose the size to be a char.
Code:
# echo aaaa | od -t oS
0000000 060541 060541 000012
0000005

# echo aaaa | od -t oC
0000000 141 141 141 141 012
0000005
The examples above show the output you were seeing on the top and one with char size input on the bottom. The 000000 and 0000005 are not part of your input, they are the starting address and the size of the input.

If you'd like to see the input interpreted as a 1:1 character output or as decimals choose these options respectively:
Code:
# echo aaaa | od -t a
0000000   a   a   a   a  nl
0000005
# echo aaaa | od -t dC
0000000   97   97   97   97   10
0000005
Hope this helps.

Last edited by crabboy; 12-15-2006 at 09:00 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
"DUMP", cron, and multiple tapes ghight Linux - Software 2 03-06-2007 03:59 AM
Box wont boot after kernel upgrade "Dump Card State Ends" error with scsi card abefroman Mandriva 0 03-25-2004 03:42 PM
"RAW" tape dump/read in Mandrake 9.2? Bob Ross Mandriva 2 01-21-2004 07:15 PM
gdb assembly dump "i386-slackware-linux" centr0 Linux - General 0 06-11-2003 11:44 AM
dump + restore to backup linux ; "Couldn't find matching filesystem: LABEL=/" on boot markus1982 Linux - General 4 09-21-2002 01:16 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:13 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration