Questions tagged [hexdump]
52 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
49
votes
2 answers
Does hexdump respect the endianness of its system?
On my machine I get the following output when I run these commands:
$ echo foos > myfile
$ hexdump myfile
6f66 736f 000a
The output from hexdump is little-endian. Does this mean that my machine is little-endian, or does hexdump always use…
Cory Klein
- 18,391
- 26
- 81
- 93
43
votes
7 answers
Is there an alternative to sed that supports unicode?
For example:
sed 's/\u0091//g' file1
Right now, I have to do hexdump to get hex number and put into sed as follows:
$ echo -ne '\u9991' | hexdump -C
00000000 e9 a6 91 |...|
00000003
And then:
$ sed…
A-letubby
- 699
- 2
- 6
- 6
14
votes
2 answers
How to interpret an octal or hex dump of a binary file?
The binary file has strings and some numbers, If I do
od -c filename or strings filename, I can see the strings properly. But, what about numbers? They are in some weird format.
The text after doing od -c filename is like this:
0000000 036 \0 032…
user14039
11
votes
3 answers
Converting from binary to hex and back
Given a binary file, how do you convert it to a hex string and back, using only standard tools like sed and cut, on a minimal system with busybox installed?
These tools are not available:
perl
python
xxd (comes with vim)
gcc
A hexdump command…
Alexander
- 9,607
- 3
- 40
- 59
10
votes
1 answer
What does `*` mean using hexdump -C?
I've been doing an exersice in attempt to understanding some of what's going on under the hood of a program. I wrote a small C program, and compiled it on i386 Linux (Ubuntu 12.04) using gcc. I then did a hexdump -C on the output to text file. I…
Chad Harrison
- 1,613
- 3
- 18
- 21
10
votes
2 answers
How to make hexdump not wait for 16 characters from stdin to display their hex values?
If I opened hexdump without any argument in the terminal:
hexdump
When I type something in the terminal and press Enter, hexdump will display the hex values for whatever characters I type.
But hexdump will only display the hex values if I type 16…
user258851
- 129
- 1
- 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
8
votes
3 answers
Hexdump of a string starting at new lines?
Say I have a multi-line strings, but the entries on it are short; if I try to hexdump, then I get something like this:
echo "something
is
being
written
here" | hexdump -C
#00000000 73 6f 6d 65 74 68 69 6e 67 0a 69 73 0a 62 65 69 …
sdaau
- 6,668
- 12
- 57
- 69
7
votes
4 answers
Get hex-only output from objdump
Say for example I've got this C function:
void f(int *x, int *y)
{
(*x) = (*x) * (*y);
}
When saved to f.c, compiling with gcc -c f.c produces f.o. objdump -d f.o gives this:
f.o: file format elf64-x86-64
Disassembly of section…
MD XF
- 191
- 1
- 3
- 13
7
votes
3 answers
Achieving hexdump-like format, that includes binary strings, on the command line?
I really like hexdump, especially because you can define a custom format; say:
$ echo -e '\x00\x01\x02\x03' | hexdump -v -e '1/1 "%_ad: "' -e '4/1 "%02X "' -e '1/1 " : "' -e '4/1 "%_p"' -e '1/1 "\n"'
0: 00 01 02 03 : ....
4: 0A : .
So, I…
sdaau
- 6,668
- 12
- 57
- 69
7
votes
3 answers
Why do ls and hexdump disagree about my file size?
I have a file I created (in vim), for testing purposes (testing UTF-8 output in an SSH client). Odd things, however, are happening to this file.
I wondered what bytes were in the file, so I used hexdump:
username@computername:~$ hexdump -x…
Mark
- 193
- 6
6
votes
2 answers
How to get Hexdump output in same format as hexedit?
I'm trying to get the output of my hexdump command to look similar to hexedit default. I've been playing with the format strings using -e, but since there are not very good documentation, that visually describe how to use it, I am failing to get it…
not2qubit
- 1,578
- 1
- 20
- 21
5
votes
2 answers
Why does hexdump try to read through EOF?
When run from a terminal, hexdump does not react to a single ^D at the beginning of the line, as cat, od, bc, etc. do, unless there was no input yet:
prompt% hexdump -C
prompt% hexdump -C
hello
# a single ^D won't…
user313992
5
votes
1 answer
How to convert hexdump to text?
I know that xxd is used to convert texts to hexdump but I want to do the opposite: convert an hex dump to text! Is there some command that I can use? Thanks for the help!
Pichi Wuana
- 1,159
- 2
- 9
- 10