Search code examples
linuxhexdumpxxd

How to save xxd or hexdump output to a simple file?


Is there a way to save the output to a file directly from the terminal? I give xxd command to a file on my terminal:

xxd image.jpg

and it gives me its contents in hex:

0003c450: 0124 9248 0492 4920 1249 2480 4924 9201  .$.H..I .I$.I$..
0003c460: 2492 4804 9249 2012 4924 8049 2492 0124  $.H..I .I$.I$..$
0003c470: 9248 0492 4920 1249 2480 4924 9201 2492  .H..I .I$.I$..$.
0003c480: 4804 9249 2012 4924 8049 2492 0124 9248  H..I .I$.I$..$.H
0003c490: 0492 4920 1249 2480 4924 9201 2492 4804  ..I .I$.I$..$.H.
0003c4a0: 9249 2012 4924 8049 2492 0124 9248 0492  .I .I$.I$..$.H..
0003c4b0: 4920 1249 2480 49db ba49 203f ffd9       I .I$.I..I ?..

What I want is to save these values in a file so that I can use them in another program. Is it possible from the terminal? If not how do I incorporate xxd or hexdump into a program?


Solution

  • This worked for me:

    xxd image.jpg > image.txt
    

    I now have a text file of the hex representation of the image.