[Vol-dev] Re: Patch: strings command optimization

RB aoz.syn at gmail.com
Tue Sep 8 19:22:51 CDT 2009


On Tue, Sep 8, 2009 at 17:37, Jesse Kornblum<research at jessekornblum.com> wrote:
> Sadly the sed scripts posted to the list do not work on the output of the OS
> X strings program. This version of strings includes leading zeros in the
> offset value. Thus, an output line from OS X strings like
>
>      0 %PDF-1.2
>
> gets converted to
>
> :     0 %PDF-1.2
>
> instead of the desired
>
> 0:%PDF-1.2

Try this one on for size (tested against strings(1) in OSX 10.5.8):

sed 's/ *\([0-9]\{1,\}\) */\1:/'

Replaces the first instance of "[optional spaces]<1 or more
numbers>[optional spaces]" with "<found number>:".  Should be a little
cleaner and quicker than firing up Perl, and if you'll notice it's
essentially the same regex you're running, if modified for sed
semantics.


More information about the Vol-dev mailing list