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
1
vote
3 answers

Unix command/s or Tcl proc to convert hex data to binary with output 1 bit per line

I have a plain text file with hex data information (32-bit word per line). Example : cafef00d deadbeef That I need to convert to this : 11001010111111101111000000001101 11011110101011011011111011101111 BUT with 1 bit per line only. Starting from…
renvill
  • 143
  • 1
  • 10
1
vote
1 answer

Issues converting a small Hex value to a Binary value

I am trying to take the contents of a file that has a Hex number and convert that number to Binary and output to a file. This is what I am trying but not getting the binary value: xxd -r -p Hex.txt > Binary.txt The contents of Hex.txt is: ff I…
Shane Becker
  • 41
  • 1
  • 1
  • 11
1
vote
1 answer

xxd converts hex file to 32 bytes binary on Mac, 30 bytes on busy box?

I am using xxd to convert a file containing the following hex private key: 608e9b6f67c65e47531e08e8e501386dfae63a540fa3c48802c8aad854510b4e simply by xxd -r -p hex > bin this command generates a binary with 32 bytes on Mac OS Big Sur xxd V1.10…
Mostafa Farghaly
  • 1,407
  • 2
  • 10
  • 15
1
vote
2 answers

How to ensure writing 4 bytes to binary file

I want to program an EEPROM which is 16/32 bit. I am writing the file from a C program, but fwrite() seems to be doing only 8 bits? I wrote a simple example, and using xxd (and hexdump) to look at the results, but the file seems to be only 8 bits. I…
Rick Dearman
  • 356
  • 2
  • 12
1
vote
1 answer

In Unix shell, how to convert from hex string to stdout bytes in machine-endian order

I'd like to run a command similar to: # echo 00: 0123456789abcdef | xxd -r | od -tx1 0000000 01 23 45 67 89 ab cd ef 0000010 That is, I'd like to input a hex string and have it converted to bytes on stdout. However, I'd like it to respect byte…
Brian
  • 2,172
  • 14
  • 24
1
vote
1 answer

Why the differences in memory address or offset between xxd and objdump?

I have the following test assembly program: .section .rodata a: .byte 17 .section .text .globl _start _start: mov $1, %eax mov a(%rip), %ebx int $0x80 And I've compiled into an executable called file. When I use objdump to disassemble…
samuelbrody1249
  • 4,379
  • 1
  • 15
  • 58
1
vote
2 answers

Convert Hex dump to ASCII

so i'm wondering if it's possible, using Bash or Python, to convert the following hex code into it's ascii output like it would have in xxd. As i've used OCR to get the text from the following image. Is there a way using bash or python that i can…
dipl0
  • 1,017
  • 2
  • 13
  • 36
1
vote
1 answer

Vim: calling xxd with system command in substitution results in conversion error

Background is that I have a log file that contains hex dumps that I want to convert with xxd to get that nice ASCII column that shows possible strings in the binary data. The log file format looks like this: My interesting hex dump: 00 53 00 6f 00…
Roger
  • 163
  • 7
1
vote
1 answer

String -> SHA -> base64, 3 ways and 3 different results via cmd tools (openssl/xxd/base64) why?

method1: $echo -n "The quick brown fox jumps over the lazy dog" | openssl sha1 | base64 MmZkNGUxYzY3YTJkMjhmY2VkODQ5ZWUxYmI3NmU3MzkxYjkzZWIxMgo= method2: $ echo -n "The quick brown fox jumps over the lazy dog" | openssl sha1 | xxd -r -p |…
RoundPi
  • 5,819
  • 7
  • 49
  • 75
1
vote
0 answers

Shrinking file with truncate, head and verifying by xxd

I use truncate on the file to check behavior of my software on incomplete files, it tuns out totally unexpected. I started to dig and ended up here. >cp full truncated >truncate -s 2485129215 truncated >ls -la -rw-r--r-- 1 yuki yuki 2485129215 Mar …
Yuki
  • 3,857
  • 5
  • 25
  • 43
1
vote
1 answer

confusion about ASCII linefeed byte in awk + xxd bash command

I am confused about some 0a (i.e. NL ASCII byte) happening in some bash commands. On the following: $ echo | sha1sum $1 | awk '{print $1;}' | xxd -r -ps > test.bin $ echo | sha1sum $1 | awk '{print $1;}' > test.hex $ xxd test.bin 00000000: adc8 3b19…
Zorglub29
  • 6,979
  • 6
  • 20
  • 37
1
vote
1 answer

Hex Dump String without whitespace

I want to convert a string into a hex using xxd. The problem is that it adds a "0a" at the end of the hex. Command: echo "hello world" | xxd -p Output: 68656c6c6f20776f726c640a Expected: 68656c6c6f20776f726c64 (without the 0a)
user5629061
1
vote
3 answers

Make sed regex alternations follow left to right precedence?

I'm trying to use a regex to format some binary from xxd -b, but to demonstrate this simply I'll show you what I expect to happen: Regex to delete: /1x|1.*/ Text: 1x21y3333333313333 -> 2 Where all occurrences of 1x are deleted, then everything…
Unihedron
  • 10,902
  • 13
  • 62
  • 72
1
vote
5 answers

Replace hex char by a different random one (awk possible?)

have a mac address and I need to replace only one hex char (one at a very specific position) by a different random one (it must be different than the original). I have it done in this way using xxd and it works: #!/bin/bash mac="00:00:00:00:00:00"…
OscarAkaElvis
  • 5,384
  • 4
  • 27
  • 51
1
vote
0 answers

Virtual addresses in Dump

Why are the virtual addresses in the dumpfiles different, when I use XDD and Radare2? Radare2-dump Xdd-dump The first image shows the Radare2-dump, the second one the xdd-dump. The addresses are not completely different. The xdd is: 000007b0…
AndiYo
  • 43
  • 6