2022 Developer Survey is open! Take survey.

Questions tagged [hex]

The tag has no usage guidance, but it has a tag wiki.

Filter by
Sorted by
Tagged with
0 votes
1 answer
10 views

How to use sh script to send hex data to /dev/ttyUSB0?

I'm working with a paired down embedded Linux installation that does not support bash, only sh across a ssh terminal. I need to send hex data to a connected USB device /dev/ttyUSB0. I'm able to do ...
user avatar
  • 235
1 vote
0 answers
45 views

Is it possible to repair a jpg that doesn't "look" broken? [duplicate]

I have many photos that were recovered a long time ago, at the time I recovered them and everything looked fine, the thumbnails produced looked good. However now, 16 years later. I see that the images ...
user avatar
0 votes
1 answer
69 views

Colour codes for 88 colours

I am looking at the colour codes Have seen the 88 colour, any idea what bit length is used for 88 colours? 3-Bit (2^3) | 8 | 8 (Primary) (000 to 111) 4-Bit (2^4) | 16 | 16 (Basic) (0000 ...
user avatar
  • 13
1 vote
3 answers
152 views

Modify and Replace $1 (awk) or \1 (sed) Values from Decimal to Hexadecimal Globally in a String?

Is it possible to Modify and Replace $1 (awk) or \1 (sed) Values from Decimal to Hexadecimal Globally in a String? It is possible that the string may contain any decimal value, which needs to be ...
user avatar
0 votes
0 answers
39 views

Editing single characters in a PDF file (generated from QPDF)

Friends, I would love your help navigating a PDF editing situation. I've extracted the PDF streams using QPDF (per the instructions here). I now have an editable PDF. My task is to replace certain ...
user avatar
1 vote
2 answers
214 views

How to grep for hex pattern w/ wildcards?

I'm trying to find the offset of a hex pattern in a file. This works for one specific value: $ grep -obUaP -m1 "\x00\x50\x53\x46\x01\x01\x00\x00\x34\x01\x00\x00" file.bin 3088:PSF4 However,...
user avatar
  • 123
0 votes
2 answers
100 views

Is there any linux utility to create plain binary dump of file and vice versa?

I want to know is there any linux utility or procedure for generating plain binary dump and reversing it back to the original file (as xxd is capable of doing it with -r argument)? I have tried xxd, ...
user avatar
  • 11
6 votes
1 answer
852 views

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 ...
user avatar
2 votes
1 answer
547 views

Reverse the effect of endianness on a memory dump

I've got a series of pipe commands that gets me a memory dump represented as a string of hexadecimal. This memory dump includes some ascii text that I want to read. The endianness of the memory dump ...
user avatar
1 vote
0 answers
100 views

How to grep for hex patterns from within a shell script?

Thanks to this thread: https://stackoverflow.com/questions/23695609/how-to-grep-for-presence-of-specific-hex-bytes-in-files I've determined that I can grep for a particular hex pattern in a file and ...
user avatar
  • 123
2 votes
1 answer
131 views

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 (...
user avatar
  • 3,317
3 votes
3 answers
269 views

Boosting the grep search using GNU parallel

I am using the following grep script to output all the unmatched patterns: grep -oFf patterns.txt large_strings.txt | grep -vFf - patterns.txt > unmatched_patterns.txt patterns file contains the ...
user avatar
0 votes
2 answers
244 views

Equivalent of grep string matching to sed & awk [closed]

I am currently processing large files looking for unmatched patterns. I am using grep to achieve this. And for some reason, grep ignores/excludes some of the potential unmatched patterns. Both the ...
user avatar
0 votes
0 answers
126 views

How to change bytes of file in HexEditor terminal

How can I add 4 characters to the start of a file by using the hexeditor (xdd) in terminal?
user avatar
0 votes
1 answer
416 views

How to print variable value as a hex number?

I can find seemingly every variation of hex manipulation by printf except this one. I am trying to send html hex colour values to a text file, built mostly using printf. I can calculate the separate R,...
user avatar
0 votes
0 answers
21 views

Kali Linux VM 2020 after upgrade converted all text to some kind of hex

I am doing some training with the OSCP shipped Kali VM. It was working fine and I got around to upgrading all packages and after I did, I get this problem. I cant even navigate to some kind of ...
user avatar
0 votes
3 answers
161 views

BASH binary to Hex to match PHP bin2hex function?

In bash I can call PHP and run the following: testKey='8798(*&98}9%"^8&]8_98{9798**76876' testHex=$(php -r "echo bin2hex('$testKey');") echo $testHex And that will result in ...
user avatar
0 votes
1 answer
242 views

Hex edit over SSH

How can you hex edit a file over SSH? I have tried using hexedit, but it says command not found. Using xxd gives the hex dump of the file, but how can I actually edit the file?
user avatar
  • 174
0 votes
1 answer
105 views

Find contents of one file in another, and replace with FF

I have a binary file called rockx.dat, and a bunch of other binary files rockx_#.pmf. I want to find the contents of the pmf files in the dat file, and replace them with FF. So if the pmf file is 500 ...
user avatar
1 vote
1 answer
505 views

Standard naming practice for executables (binary file) and how to tell whether a file has has non-printable characters?

So I am often guilty of running cat on an executable file that's a binary file and my terminal usually makes some weird noises and isn't happy. Is there some accepted naming convention for giving an ...
user avatar
0 votes
1 answer
3k views

Convert received data bytes in serial to hex text

Hi now I write bytes data (for eg, \x00\x11\x22) from my PC to serial port of my device running unix at the ttyS1 port. I am able to print the data using either cat /dev/ttyS1 od -x < /dev/ttyS1 ...
user avatar
  • 127
2 votes
1 answer
2k views

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 ...
user avatar
  • 148
2 votes
2 answers
1k views

Undump od (octal or hex dump) in Version 6 Unix

od (octal dump) command is implemented in Unix since Version 1. However, I couldn't find a reverse command in the Version 6 Unix manual (1975). Modern ways of reversing od with either xxd or sed do ...
user avatar
3 votes
3 answers
596 views

How can I list the different hex characters between two files?

allHexChars.txt \x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\...
user avatar
  • 155
-1 votes
1 answer
100 views

How do we get the readable string from big endian hex string

How do we get the readable string from hex string 0049006e00740072006f of BE which means as normal word, ie. we dont have to swap the byte pair per word tried with xxd in vain, cause I dont know ...
user avatar
7 votes
2 answers
7k views

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-...
user avatar
2 votes
1 answer
559 views

Hex code for '(' in bash regex

I have a strange behaviour in shell. When I try to match '_' in regex with its hex code it works, but not with '('. $ regex1=$'\x5f' $ pattern1='_' $ if [[ $pattern1 =~ $regex1 ]]; then echo yes; ...
user avatar
  • 31
3 votes
1 answer
1k views

Can you edit address values in "/proc/$pid/mem" to reflect changes in that process?

I would like to see if I can edit a value in my program while it is running by directly changing the memory. My thought process (untested) is to do the following: Run the program. Open up "System ...
user avatar
  • 183
4 votes
1 answer
8k views

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

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 ...
user avatar
  • 121
-2 votes
2 answers
333 views

Reverse engineering the hex file [closed]

reverse engineering the hex file Written in c language From atmega16 Want source code from the hex code By reverse engineering need to extract the library file of the code is their any possible ...
user avatar
5 votes
2 answers
10k views

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 ...
user avatar
  • 171
0 votes
4 answers
1k views

Finding how many hex values a string containing hex and random string

I have the file ~/dummy_hex.txt containing hex and random string: \x12\xA1\xF1\xE3somegibberigh I want to count how many hex values (groups of \x^hex_digit^^hex_digit^) the string above has. In the ...
user avatar
6 votes
3 answers
2k views

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 ...
user avatar
2 votes
2 answers
5k views

printf in shell script can't do \x%x

where ECHO-VAR produces \xFF\xFF\xFF\x00 ($fb_COLOR15) these work on the command line: CP="`ECHO-VAR`" printf $CP | dd status=none bs=4 count=$(( ( 1360 * 100 ) + 100 )) > /dev/fb0 printf "`ECHO-...
user avatar
2 votes
1 answer
7k views

Find hex value in files/folder

Is there a way to search for a hex value in files / folders? I've tried the following: grep -P "[\x01\x02\x03]" but that doesn't work (there is no error, but it doesn't search for these hex values).
user avatar
  • 121
0 votes
1 answer
561 views

Hex viewer for Solaris (SunOS 5.11)

Can anyone point me at a decent hex viewer for Solaris? Looking for something with a front-end similar to bless on Ubuntu or Binary Viewer on Windows or ..almost the Delta Hex Editor Netbeans plugin. ...
user avatar
  • 319
2 votes
1 answer
1k views

Why does xxd not show the byte order mark?

I have a Java class which the compiler refuses to compile due to \ufeff at the start of the file. I can view the fact that the BOM is present by vim -b file.java, but neither xxd nor hexdump show the ...
user avatar
  • 306
0 votes
1 answer
1k views

Command for converting little endian memory addresses to hex code?

I'm wondering is there's a command or utility already built within the terminal that can take a little endian memory address (for e.g. 5F4A358F) and convert it into a hex code (in this case \x8f\x35\...
user avatar
  • 155
1 vote
2 answers
550 views

swap bits position in linux

i have hex value B455 when i change it to binary i got 1011 0100 0101 0101 i want to swap the bits with a rule of : origin bits index : 0123456789ABCDEF result bits index : D5679123C4EF80AB` ...
user avatar
12 votes
3 answers
3k views

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....
user avatar
11 votes
6 answers
9k views

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 ...
user avatar
19 votes
4 answers
27k views

How to calculate hexadecimal xor (^) from shell?

Unfortunately bc and calc don't support xor.
user avatar
  • 542
0 votes
1 answer
147 views

Hex has unknown character / in the output

I need to create a Rc2Key variable and then convert this to hexadecimal. I have done this with two commands. The Rc2Key variable has to be 16 characters long, so in my test module I used "...
user avatar
  • 17
2 votes
1 answer
6k views

Grep is not matching non-ascii characters

I found a problematic sequence of a supposedly UTF-8 encoded text file. The strange thing is that grep seems unable to match this non-ASCII line. $ iconv -f utf8 -t iso88591 corrupt_part.txt --output ...
user avatar
  • 163
3 votes
2 answers
1k views

How can I do a binary search of a text file for a specific character string?

I have a text file that contains a large number of records, each on a single line. Some of the records have special characters that have been corrupted, and I'm attempting to find those by looking for ...
user avatar
  • 41.3k
1 vote
2 answers
440 views

Appending Echo [Password Generator]

I am creating a password generator however I am not get the passwords to append properly. Here is my script i="0" while [ $i -lt 5 ] do echo -n '#' >> passwords.txt && openssl rand ...
user avatar
2 votes
2 answers
865 views

How to use grep to return lines with an hexadecimal number in a given range?

If I have, say: blah;PC=1234abcd PC=4444bbcd;blah PC=0000abcd;;foo PC=1234abff How do I grep for lines with PC values in a given range, say 1234ab00 to 1234b0ff. The - range option seems to only ...
user avatar
  • 147
2 votes
1 answer
153 views

Bash script: hex

I'm trying to do the following: ch='\x21' line="\x21" len=50 for i in `seq 1 $len` do line+="$ch" done Instead of 50 '!' (hex code \x21) I get a list of 50 '\x21'. How can I do this in bash?
user avatar
  • 23
2 votes
2 answers
1k views

How to convert an special hex character from an html page in bash? [duplicate]

I have a script which process some information coming from a web page. I guess that because of the encoding of the page, some special characters are encoded in hexadecimal. For example, I have the the ...
user avatar
2 votes
2 answers
2k views

DASH hexadecimal string comparison

I am attempting to compare two strings containing hexadecimal numbers in a dash test, one which has leading zeros and one which doesn't: hex_string_1: 0x02a0000b hex_string_2: 0x2a0000b Trying if [ $...
user avatar
  • 41