Date: Tue, 19 Oct 2010 21:21:00 -0400 (EDT) From: vogelke+unix@pobox.com (Karl Vogel) To: freebsd-questions@freebsd.org Subject: Re: filter a binary file and reduce 0x150a to 0x15 Message-ID: <20101020012100.938F5BF78@kev.msw.wpafb.af.mil> In-Reply-To: <20101019130845.GA3773@current.Sisis.de> (message from Matthias Apitz on Tue, 19 Oct 2010 15:08:45 %2B0200) References: <20101019130845.GA3773@current.Sisis.de>
next in thread | previous in thread | raw e-mail | index | archive | help
>> On Tue, 19 Oct 2010 15:08:45 +0200, >> Matthias Apitz <guru@unixarea.de> said: M> Before I programm it in C (or whatever), is there any normal shell tool M> to filter a (large) binary file and change any occurance of 0x150a to M> 0x15 (i.e. delete \n but only if it follows a char 0x15)? This seems to work, depending on your definition of normal: me% od -c blah 0000000 025 025 H e l l o 025 \n w o r l d . \n 0000020 me% perl -0pe 's/\025\n/\025/g;' < blah | od -c 0000000 025 025 H e l l o 025 w o r l d . \n 0000017 The "-0" says read null-terminated lines, so if your binary file is big enough and has few enough nulls, you could chew up a diaper-load of memory. -- Karl Vogel I don't speak for the USAF or my company A raccoon tangled with a 23,000 volt line today. The results blacked out 1400 homes and, of course, one raccoon. --Steel City News
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20101020012100.938F5BF78>