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?
CodePudding user response:
This worked for me:
xxd image.jpg > image.txt
I now have a text file of the hex representation of the image.
CodePudding user response:
My guess is that when you say you want to use the output "in another program", you mean you're going to compile it into something. This is what the -i
option is for: generate an include file:
xxd -i image.jpg > image.h
Then #include
image.h in your project and use the associated variables.