filter a binary file and reduce 0x150a to 0x15

Matthias Apitz guru at unixarea.de
Tue Oct 19 13:49:24 UTC 2010


El día Wednesday, October 20, 2010 a las 12:36:44AM +1100, andrew clarke escribió:

> I'd be personally more comfortable doing it in C or Python but I think
> you can do this with tr -s.

me too;

> 
> Note: 0x15 == 25 octal; 0x0a == 12 octal.  I don't recall if it's
> possible to use hex values in csh arguments - if so, what is the
> syntax?
> 
> 0:28 ozzmosis at blizzard [~/tmp]printf 'Hello\25\12world.\12' > blah
> 
> 0:28 ozzmosis at blizzard [~/tmp]hd blah
> 00000000  48 65 6c 6c 6f 15 0a 77  6f 72 6c 64 2e 0a        |Hello..world..|
> 0000000e
> 
> 0:28 ozzmosis at blizzard [~/tmp]tr -s '\25\12' '\25' < blah | hd
> 00000000  48 65 6c 6c 6f 15 77 6f  72 6c 64 2e 15           |Hello.world..|
> 0000000d

I saw this, but this has the side affect to reduce any occourance of a
duouble 0x1515 to 0x15:

guru at current:~> printf '\25\25Hello\25\12world.\12' > blah
guru at current:~> hd blah
00000000  15 15 48 65 6c 6c 6f 15  0a 77 6f 72 6c 64 2e 0a |..Hello..world..|
00000010
guru at current:~> tr -s '\25\12' '\25' < blah | hd
00000000  15 48 65 6c 6c 6f 15 77  6f 72 6c 64 2e 15 |.Hello.world..|

Thanks anyway

	matthias

-- 
Matthias Apitz
t +49-89-61308 351 - f +49-89-61308 399 - m +49-170-4527211
e <guru at unixarea.de> - w http://www.unixarea.de/


More information about the freebsd-questions mailing list