Reverse hexdump without xxd | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Reverse hexdump without xxd

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 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
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
    #2  
Old 03-16-2010
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
 
Join Date: Feb 2004
Last Activity: 27 November 2014, 8:24 AM EST
Location: NM
Posts: 10,283
Thanks: 288
Thanked 815 Times in 757 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.
try

Code:
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
    #3  
Old 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 973 Times in 789 Posts
Assuming the values are space-delimited single bytes in hex:

Code:
$ cat hdump
41 42 43 44
45 46 47 48

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

Regards,
Alister

Last edited by alister; 03-16-2010 at 10:31 PM..
    #4  
Old 03-17-2010
pludi's Avatar
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
Code:
> rpm -qf $(which xxd)
vim-base-7.1-44.2

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 Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 04:42 PM.