Questions tagged [xxd]

26 questions
51
votes
6 answers

How to dump a binary file as a C/C++ string literal?

I have a binary file I would like to include in my C source code (temporarily, for testing purposes) so I would like to obtain the file contents as a C string, something like this: \x01\x02\x03\x04 Is this possible, perhaps by using the od or…
Malvineous
  • 6,524
  • 5
  • 52
  • 76
25
votes
2 answers

xxd output without line breaks

Can I tell xxd to not print any line breaks in its output and have my dump as one continuous line? [user@localhost] : ~ $ echo -n "this is a long line and xxd is going to take multiple lines to print it" | xxd…
Juicy
  • 3,685
  • 11
  • 31
  • 44
10
votes
2 answers

How to print zeros and ones of a file

Long story short: how to print in a terminal the binary digits constituting a file e.g. a library .so or a simple text .txt file PC hardware works with electrical signal (basically it's an ON/OFF behaviour) which is well logically translated by the…
mattia.b89
  • 3,142
  • 2
  • 14
  • 39
8
votes
1 answer

Why is 0x00 being deleted when assigning a base64 decoded string to a variable

I'm using a Mac. In Bash, I'm trying to decode a base64 string and then try to print the Hex value. I'm using base64 -d command and then assigning it to a variable. myText='YYN29+2wV2XRAHymIyhgytWuqY4atgHnIUFfXA7FPOA=' myTextBytes=$(echo -n…
SilleBille
  • 191
  • 5
8
votes
2 answers

What is the difference between the od, hd, hexdump and xxd commands?

What is the difference between the od, hd, hexdump and xxd commands ? They are all commands for dumping files and they can all dump it in various formats such as hexadecimal, octal or binary. Why creating different programs ?
Nicryc
  • 285
  • 4
  • 11
7
votes
2 answers

Any way to send just "\n" in Telnet?

I'm wondering if there's any way to get telnet to send only a \n, not a \r\n. For example, if one process is listening on a port like this, to print the bytes of any traffic received: nc -l 1234 | xxd -c 1 Connecting to it from netcat with nc…
shelly
  • 81
  • 1
  • 1
  • 3
4
votes
1 answer

Hex dump only the beginning and the end of a file with xxd

I am looking for a command to display three .png files using xxd, displaying the first two and last two lines of the hexadecimal for each. I have used the command below to display one file at a time but I am wondering if there is a command that can…
Deirdre
  • 121
  • 2
  • 2
  • 8
4
votes
3 answers

Split binary data of fixed byte offset by byte position?

I have binary data which I review by xxd -ps in hex format. I notice that the byte distance is 48300 (=805*60) bytes between two headers where the separator is fafafafa. There is the beginning of the file which should be skipped. Example hex data…
Léo Léopold Hertz 준영
  • 6,788
  • 29
  • 91
  • 193
2
votes
2 answers

How to format hexdump as xxd, possible for xxd -revert?

I wish to dump the raw content of a SD card into a file for inspection. Most parts of it are zeroes. Learnt from this SuperUser answer I could use pv to show the progress of od and hexdump. Both ETA are 1.5 hours. # pv /dev/sdd | od -x --endian=big…
midnite
  • 325
  • 1
  • 3
  • 13
2
votes
1 answer

How to modify a hex string to LE-format before passing it to `xxd -r` to view its binary contents?

The hex string 0068732f6e69622f represents the ASCII string /bin/sh, when it's stored in memory in LE-format. Is there any Linux utiltity that will take the hex string and reverse it bytes (2f62696e2f736800), such that xxd -r -ps will display…
Shuzheng
  • 4,023
  • 1
  • 31
  • 71
2
votes
1 answer

Make xxd display the the byte offset at the top column?

So Im using emacs which has a stupendous hexl-mode to view the byte offset in a file right over the hex values similar to: 87654321 0011 2233 4455 6677 8899 aabb ccdd eeff 0123456789abcdeff 00000000: 5765 6c63 6f6d 6520 746f 2047 4e55…
LFMekz
  • 148
  • 7
2
votes
2 answers

xxd with 64 bit addresses

I find xxd to be nice and convenient for simple manipulation of binary data in the terminal. However it has a limitation in that all addresses outputted by the program is limited to 32 bits. E.g. root:/# xxd -s 0x5baae0000 /dev/sda baae0000: 2d7c…
Christer
  • 186
  • 1
  • 8
2
votes
2 answers

Unix: Using the xxd Command on a ppm File

I am fairly new to unix and am having trouble understanding what some of the commands do.For example, when I use xxd on a ppm file (i.e. xxd image.ppm) I get an output like this: 00000000: 5036 0a31 3131 2031 3332 0a32 3535 0a55 P6.111…
Shoaib Ahmed
  • 21
  • 1
  • 1
  • 2
2
votes
1 answer

How to make "xxd" place spaces between the hex values?

I am using the following command to read the output of one terminal from another terminal: xxd -p /dev/pts/0 But there is no spaces between the hex values, for example I get something like this: 61626162 Instead of this: 61 62 61 62
Tom
  • 123
  • 1
  • 11
2
votes
1 answer

Make xxd break lines

For showing the content of a file with both formatted text and binary data inside in another post on SE I couldn't decide on wheather to show the ASCII rendered output or a the xxd output. As a middle course I thought about a hexdump that does…
stuquus
  • 23
  • 3
1
2