[X-Unix] How does one find a string in a binary file, etc.?

Aaron aaron at macuser.fastmail.fm
Fri Sep 5 04:15:09 PDT 2008


>From: Kevin Stevens <groups at pursued-with.net>
>Date: Tue, 2 Sep 2008 19:23:11 -0700
>
>On Sep 2, 2008, at 09:06, Aaron wrote:
>
>> Thanks, Björn, for your quick response.
>>
>>> From: "B. Kuestner" <kuestner at macnews.de>
>>> Date: Tue, 2 Sep 2008 15:43:00 +0200
>>>
> >> Try "man strings".
>>
> > That gets a negative result. "man string" turns up a bunch of C 
>> functions. "apropos string" turns up lots and lots of C functions 
>> and a few other useless items. Am I missing something?
>
>You're missing an "s" on the end of "string"...

I had, as I meant to make clear, tried both "man string" and "man strings". But it turns out that what I was missing was XcodeTools. I hadn't installed it on my Leopard (10.5.4) startup volume that I just started using a couple of weeks ago. (Previously I had been using Tiger with Xcode 2.4 or 2.5.) I downloaded Xcode 3.0, did a standard install and, voila!, "man strings" works!

While I can imagine writing a script using "strings", it seems rather an awkward approach, since it finds all text strings in the file at all locations.

I'm working now on a script to (1) split the 512-MB files one at a time into 1-MB files; (2) split the 1-MB files one at a time into 4-KB files; and (3) test each 4-KB file, saving the ones that match the desired pattern. It requires that I relearn a lot of csh/tcsh syntax details that I knew like the back of my hand 20 years ago. (I know that most people prefer other shells, but I'm going with the one I've used a lot in the past. If I were going to put the time into learning another shell, I'd rather learn Perl or Tcl/Tk instead.)

Also, in order to avoid more accidents like the one I described in "[X-Unix] Urgent question about accidentally deleted files", I'm going to move around the files for testing this script so I can do the whole thing from a new, temporary user account.

 - Aaron



More information about the X-Unix mailing list