Unix/Linux Go Back    

Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Reverse hexdump without xxd

Shell Programming and Scripting

Thread Tools Search this Thread Display Modes
Old Unix and Linux 03-16-2010   -   Original Discussion by LessNux
LessNux LessNux is offline
Registered User
Join Date: Jan 2010
Last Activity: 25 February 2014, 10:15 PM EST
Posts: 40
Thanks: 14
Thanked 1 Time in 1 Post
Unix or Linux Question Reverse hexdump without xxd

The "hexdump" command cannot perform reverse operation. On the other hand, the "xxd" command with -r option performs reverse hexdump, while the "xxd" command without -r performs the (forward) hexdump. An example of hexdump is to convert ABCD into 41 42 43 44. An example of reverse hexdump is to convert 41 42 43 44 back into ABCD.

The command "xxd" comes with Mac OS X. However, Linux may not come with "xxd". On a Linux that does not come with "xxd", how can reverse hexdump be achieved? Perhaps, vi editor?

Thanks in advance.
Sponsored Links
Old Unix and Linux 03-16-2010   -   Original Discussion by LessNux
jim mcnamara jim mcnamara is offline Forum Staff  
Join Date: Feb 2004
Last Activity: 22 November 2017, 2:26 PM EST
Location: NM
Posts: 11,240
Thanks: 571
Thanked 1,117 Times in 1,031 Posts
xxd is available on most linux distros, it just may not be installed on yours, for whatever reason. It is definitely part of the standard install AFAIK.

find / -type f -name xxd

xxd(1): make hexdump/do reverse - Linux man page

Duplicating what it does is not simple, IMO, because it requires a parser, endian understanding, etc. You are far better off finding it on your box, or installing it.
Sponsored Links
Old Unix and Linux 03-16-2010   -   Original Discussion by LessNux
alister alister is offline
Registered User
Join Date: Dec 2009
Last Activity: 11 June 2014, 8:40 PM EDT
Posts: 3,231
Thanks: 179
Thanked 976 Times in 790 Posts
Assuming the values are space-delimited single bytes in hex:

$ cat hdump
41 42 43 44
45 46 47 48

echo 'ibase=16' | cat - hdump | tr ' ' \; | bc | awk '{printf("%c",$0)}'


Last edited by alister; 03-16-2010 at 10:31 PM..
Old Unix and Linux 03-17-2010   -   Original Discussion by LessNux
pludi's Unix or Linux Image
pludi pludi is offline Forum Advisor  
Cat herder
Join Date: Dec 2008
Last Activity: 28 March 2014, 8:35 AM EDT
Location: Vienna, Austria, Earth
Posts: 5,521
Thanks: 38
Thanked 335 Times in 308 Posts
xxd is part of VIm. On OpenSuSE 10.3
> rpm -qf $(which xxd)

So unless you're on an emacs/nano only system, you should have access to it. Note that *Ubuntu and Gentoo by default only ship nano, so you'll have to install VIm yourself.
Sponsored Links

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to reverse output? a2156z Shell Programming and Scripting 4 01-12-2009 04:44 AM
reverse an integer ali560045 Shell Programming and Scripting 4 05-20-2008 04:15 AM
Reverse FTP ganesh123 Shell Programming and Scripting 4 02-22-2007 02:20 PM
reverse of basename braindrain Shell Programming and Scripting 7 10-03-2006 03:24 AM
Reverse * azmathshaikh Shell Programming and Scripting 2 04-26-2005 08:40 AM

All times are GMT -4. The time now is 03:03 AM.