Questions tagged [hex]

Hexadecimal (also base 16, or hex) is a numeral system with a base of 16. It uses sixteen distinct symbols, most often the symbols 0–9 to represent values zero to nine, and A, B, C, D, E, F (or alternatively a–f) to represent values ten to fifteen.

Each hexadecimal digit represents four binary digits (bits), and the primary use of hexadecimal notation is a human-friendly representation of binary-coded values in computing and digital electronics. More information may be found here.

Other numeral systems:

68 questions
63
votes
4 answers

BASH base conversion from decimal to hex

In Bash, how does one do base conversion from decimal to another base, especially hex. It seems easy to go the other way: $ echo $((16#55)) 85 With a web-search, I found a script that does the maths and character manipulation to do the conversion,…
Dave Rove
  • 1,235
  • 1
  • 12
  • 9
19
votes
4 answers

How to calculate hexadecimal xor (^) from shell?

Unfortunately bc and calc don't support xor.
Costa
  • 552
  • 1
  • 3
  • 10
18
votes
2 answers

passing dd skip|seek offset as hexadecimal

# dd if=2013-Aug-uptime.csv bs=1 count=1 skip=3 2> /dev/null d # dd if=2013-Aug-uptime.csv bs=1 count=1 skip=0x3 2> /dev/null f Why the second command outputs a different value? Is it possible to pass the skip|seek offset to dd as an hexadecimal…
eadmaster
  • 1,573
  • 4
  • 18
  • 30
12
votes
3 answers

Bash expansion hexadecimal

I would like to know if there is a way of using bash expansion to view all possibilities of combination for a number of digits in hexadecimal. I can expand in binaries In base 2: echo {0..1}{0..1}{0..1} Which gives back: 000 001 010 011 100 101 110…
David Borges
  • 155
  • 1
  • 9
11
votes
6 answers

Reverse a hexadecimal number in bash

Is there a simple command to reverse an hexadecimal number? For example, given the hexadecimal number: 030201 The output should be: 010203 Using the rev command, I get the following: 102030 Update $ bash --version | head -n1 GNU bash, version…
Iñaki Murillo
  • 745
  • 1
  • 4
  • 14
10
votes
1 answer

Space not taken as an argument separator by shell script (could someone please explain that small file difference ?)

SHORT VERSION (TL;DR) I have 2 small one-line files, seemingly identical : $ cat f1 f2 ./cconv.sh 100 EUR USD ./cconv.sh 100 EUR USD But they are not, there is a 1 byte difference in size : $ ls -l f1 f2 (...) 24 oct. 30 16:19 f1 (...) 23 oct. 30…
ChennyStar
  • 1,319
  • 9
  • 22
8
votes
2 answers

How to read string as hex number in bash?

I have the bash line: expr substr $SUPERBLOCK 64 8 Which is return to me string line: 00080000 I know that this is, actually, a 0x00080000 in little-endian. Is there a way to create integer-variable from it in bash in big-endian like 0x80000?
DenisNovac
  • 285
  • 2
  • 3
  • 10
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
2 answers

How to write binary values into a file in Bash instead of ASCII values

I am dealing with an embedded system which has some memory that is accessible by a file descriptor (I have no idea what am I saying, so please correct me if I am wrong). This memory is 32 kB and I want to fill it with 0x00 to 0xFFFFFFFF. I know this…
DEKKER
  • 834
  • 8
  • 18
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
6
votes
1 answer

grep should find a hex value in a file but doesn't

Here is the beginning of a file: # hexdump -n 550 myFile 0000000 f0f2 f5f0 f7f9 f1f1 f1f0 f0f0 e3f1 f3c8 0000010 f3f5 0000 0000 000c 0000 0000 0000 000c 0000020 0000 0c00 0000 0000 0000 0c00 0000 0000 0000030 000c 0000 0000 0000 000c 0000 0c00…
mcoulont
  • 71
  • 3
6
votes
2 answers

convert hex IP address into hostname

I would like to switch between hostnames and hex IP addresses, and vice versa. I have installed syslinux-utils on Debian Stretch, which provides gethostip: gethostip -x google.com D83ACD2E How can I switch D83ACD2E back to hostname? In older…
Martin Vegter
  • 69
  • 66
  • 195
  • 326
5
votes
1 answer

What is the meaning of Star symbol * in Hex data?

I see sometimes star symbol (*) in the hex editor, like ... 00001d0 0000 0000 0000 0000 0000 0000 0000 0000 * 00001f0 0000 0000 0000 0000 0008 0000 0000 0000 ... It is probably some sort of separator. However, there are many other separators too.…
Léo Léopold Hertz 준영
  • 6,788
  • 29
  • 91
  • 193
5
votes
2 answers

In emacs, is there a way to Hex edit/view a buffer without losing the undo info?

When I use hexl-mode in emacs, it discards the buffer's undo info. Is there another way to hex-edit the buffer and yet retain the undo info? If there is no alternative hex-editor, is there a hex-viewer which can view the buffer? I have tried…
Peter.O
  • 32,426
  • 28
  • 115
  • 163
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
1
2 3 4 5