Unix/Linux Go Back    

Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

Reverse hexdump without xxd

Shell Programming and Scripting

Closed Linux or Unix Question    
Thread Tools Search this Thread Display Modes
Old Unix and Linux 03-16-2010
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
jim mcnamara jim mcnamara is offline Forum Staff  
Join Date: Feb 2004
Last Activity: 31 May 2016, 9:21 AM EDT
Location: NM
Posts: 10,741
Thanks: 414
Thanked 941 Times in 874 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
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 975 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 09:31 PM..
Old Unix and Linux 03-17-2010
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,522
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
Closed Linux or Unix Question

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 03:44 AM
reverse an integer ali560045 Shell Programming and Scripting 4 05-20-2008 03:15 AM
Reverse FTP ganesh123 Shell Programming and Scripting 4 02-22-2007 01:20 PM
reverse of basename braindrain Shell Programming and Scripting 7 10-03-2006 02:24 AM
Reverse * azmathshaikh Shell Programming and Scripting 2 04-26-2005 07:40 AM

All times are GMT -4. The time now is 11:33 PM.