filter a binary file and reduce 0x150a to 0x15
Karl Vogel
vogelke+unix at pobox.com
Wed Oct 20 01:49:22 UTC 2010
>> On Tue, 19 Oct 2010 15:08:45 +0200,
>> Matthias Apitz <guru at 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
More information about the freebsd-questions
mailing list