Questions tagged [xxd]

`xxd` is a Linux Hexdump command

On the Linux platform, the command xxd (available via most package managers) works as a hexdump tool.

From man xxd

xxd creates a hex dump of a given file or standard input. It can also 
convert a hex dump back to its original binary form. Like uuencode(1) and 
uudecode(1) it allows the transmission of binary data in a `mail-safe' ASCII 
representation, but has the advantage of decoding to standard output. 
Moreover, it can be used to perform binary file patching.  
107 questions
0
votes
1 answer

In C++, how do you read a file that is embedded in an executable?

I had a photo named photo.jpg. I used xxd -i to generate a C++ file for my image file. And the output is something like this: unsigned char photo_jpg[] = {     0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01,     0x01, 0x01,…
0
votes
1 answer

How does 95cd 21eb fc from Farbrausch's "fuenf" translate into

In 2001 German scene group Farbrausch released a demo called "fuenf" (in your face). pouet.net It contains a 5 Byte executable which could be rather considered a troll approach than a demo. If you run it your hear a weird sound and it could crash…
n.r.
  • 831
  • 1
  • 11
  • 30
0
votes
2 answers

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:…
0
votes
2 answers

Get java compiler version of a class file using xxd

I need to get the version of java that was used to compile a class file from a linux machine that doesn't have java. I have learned from a comment on this post that this is possible using xxd. Alternatively, if you open the class file in a hex…
Jack J
  • 1,514
  • 3
  • 20
  • 28
0
votes
1 answer

xxd usage (change magic byte to JPEG)

I create a simple test file like this: $ cat > test blah Now I run vi, and then :%!xxd to edit first bytes with FFD8 FF 00000000: ffd8 ffe0 0a blah. and the I run :%!xxd -r. file gives me NOT jpeg: $ file test test:…
hap78
  • 29
  • 1
  • 3
0
votes
1 answer

Display Top 5 Lines From Unix Command Output

I am trying to display only the first 5 or so lines of Unix command xxd file/path.dmg similarly to the head() command in r. As of now, I am simply trying to spam "ctrl + c" to halt execution as fast as possible, but unsurprisingly I'm not fast…
0
votes
2 answers

How to make a c++ header file smaller? The header file is generated with "xxd -i"

We need to store some data as c++ header file, so that we can then include it in the build bundle and shipped with any applications that use it. To do that we use xxd -i data.png > data.h This works well, but the data.h files is now as 6X large as…
0
votes
1 answer

An alternative in php to the xxd command in linux

I need to convert the bin file to a string in PHP in the same way as the Linux program does. In linux: xxd -g 1 data.bin and output: 0000000: 02 50 45 10 02 06 54 62 43 20 05 20 11 07 21 12 .PE...TbC . ..!. In PHP, I tried to use the bin2hex…
Krystian
  • 47
  • 7
0
votes
1 answer

How to convert hex to ASCII while preserving non-printable characters

I've been experiencing some weird issues today while debugging, and I've managed to trace this to something I overlooked at first. Take a look at the outputs of these two commands: root@test:~# printf '%X' 10 | xxd -r -p | xxd -p root@test:~# printf…
InterLinked
  • 1,247
  • 2
  • 18
  • 50
0
votes
1 answer

Writing 16 bits to a file (and being sure it is happening)

UPDATE: Updated the code and the xxd output. I asked this question before, but I don't believe I explained it well enough to get an answer. I am attempting to generate a file to load on to an EPROM like in the photo. I need to create a binary file…
Rick Dearman
  • 356
  • 2
  • 12
0
votes
1 answer

How do you get plain text from binary where the plaintext is formatted by itself?

Desired output of something like "xxd -b file": 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 ..etc then followed by plaintext here Actual output: 00000000 00000000 00000000 00000000 plai 00000000 00000000 00000000…
Tyk
  • 68
  • 9
0
votes
1 answer

How to see what various control characters are as sent by my keyboard

Usually I will use xxd to see what characters I type translate to in hex. For example: $ xxd hello 00000000: 0a68 656c 6c6f 0a .hello. However, how would I do the same for: Ctrlz Ctrld Ctrlc It seems when I enter either of…
carl.hiass
  • 1,526
  • 1
  • 6
  • 26
0
votes
1 answer

Different representations for dot in binary

I have a code in C which simply prints hello world, like this #include int main(void) { printf("Hello, world\n"); } to compile the code in ubuntu I used the command make filename which gives me an assembly code like this: .text …
Abdelrahman Emam
  • 385
  • 1
  • 6
  • 15
0
votes
1 answer

How to convert hexadecimal hash into binary at terminal?

Main question: How to use xxd -r? Secondary details. This command outputs a hexadecimal hash: openssl dgst -sha256 myFile | awk '{print $2}' > myHashHex I suppose that myHashHex is a "hexdump", isn't it? I thought that xxd -r < myHashHex will…
Peter Krauss
  • 13,174
  • 24
  • 167
  • 304
0
votes
2 answers

xxd in bash: remove line numbers and ascii

So I was wondering how to remove the linenumbers and the ascii while outputting data with xxd. The code: chst1="$(xxd -u -p -l1 -s 765 "$d2s")" chst2="$(xxd -u -p -l1 -s 766 "$d2s")" chst3="$(xxd -u -p -l1 -s 767 "$d2s")" chst4="$(xxd -u -p -l1 -s…
user14136230