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

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue 2010-10-19 15:08:45 UTC+0200, Matthias Apitz (guru@unixarea.de) wrote:

> Before I programm it in C (or whatever), is there any normal shell tool
> to filter a (large) binary file and change any occurance of 0x150a to
> 0x15 (i.e. delete \n but only if it follows a char 0x15)?

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

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

Regards
Andrew



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