command or script for converting hex values to text

Mogens Kjaer mk at crc.dk
Fri Sep 22 09:07:21 UTC 2006


ankush grover wrote:
...
> Important is accepting the file as input and converting all the values
> in it to text values
> 
> 41 65 72 74 3A 20 49 6E 74 65 72 66 61 63 65
> 
> the output of the above should be "APRIL FOOL".

If you file contains a mixture of hex and plain
text, a perl one-liner could do the trick:

$ perl -pe 's/[0-9A-Fa-f][0-9A-Fa-f]\s+/chr(hex($&))/ge' input.dat
Aert: Interface

You might have to change the whitespace part of the RE.

Mogens

-- 
Mogens Kjaer, Carlsberg A/S, Computer Department
Gamle Carlsberg Vej 10, DK-2500 Valby, Denmark
Phone: +45 33 27 53 25, Fax: +45 33 27 47 08
Email: mk at crc.dk Homepage: http://www.crc.dk




More information about the fedora-list mailing list