I've got a text file that I'm trying to debug an encoding issue in. I ran the file through od -c and got the following output:

3457540  ,   "   t   e   x   t   "   :   "   302 241   Q   u 303 251

My understanding from the man page is that -c "select[s] ASCII characters or backslash escapes." I guess I don't understand what a backslash escape is. I would have assumed it to be a C-string style escaped character, such as \0 or \n. However, I'm getting values (302 and 303) that are clearly out of the range of a byte. Could somebody explain what's happening here?

  • 1
    Guess what o means in od ;-) – jlliagre Mar 14 '14 at 22:01
  • 1
    @jlliagre Yeah, I knew that it meant octal dump, but apparently I'm having a derp day. – Eric Andres Mar 14 '14 at 23:22

Those numbers are octal (base 8) It'll only backslash something that has a symbolic name (\n, \b, \t, etc.)

(I prefer hd -- hexdump -C -- myself.)

  • Ah, I forgot that a lot of these tools were written for octal first. That would explain the oddball numbers. Thanks, hd looks like the better option. FYI, the -c switch is lower case (at least on Ubuntu). – Eric Andres Mar 14 '14 at 21:38
  • No, lowercase "c" is different from uppercase for the parent hexdump application. – Ricky Mar 14 '14 at 21:41
  • You're right. I was thinking hd was an alias for hexdump. Thanks again. – Eric Andres Mar 14 '14 at 21:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.