Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 19 Oct 2010 15:49:24 +0200
From:      Matthias Apitz <guru@unixarea.de>
To:        andrew clarke <mail@ozzmosis.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: filter a binary file and reduce 0x150a to 0x15
Message-ID:  <20101019134924.GA4076@current.Sisis.de>
In-Reply-To: <20101019133644.GA70489@ozzmosis.com>
References:  <20101019130845.GA3773@current.Sisis.de> <20101019133644.GA70489@ozzmosis.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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@blizzard [~/tmp]printf 'Hello\25\12world.\12' > blah
> 
> 0:28 ozzmosis@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@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@current:~> printf '\25\25Hello\25\12world.\12' > blah
guru@current:~> hd blah
00000000  15 15 48 65 6c 6c 6f 15  0a 77 6f 72 6c 64 2e 0a |..Hello..world..|
00000010
guru@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@unixarea.de> - w http://www.unixarea.de/



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20101019134924.GA4076>