Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Flux Harmonic

macrumors member
Original poster
May 10, 2005
66
0
Canada
I've come upon a situation whereby I have to edit a bunch of log files, junking the same text from each one. Ideally I'd just like to be able to run the logs through automator, and have it erase certain strings, rather than go into each one and do a series of replace-alls.

Has anyone figured out how to do this?
 
What you really need to do is write a script that used the "sed" editor to edit the files..And then you could use automator to run that.

For more details on sed: "man sed" from the terminal.

I haven't used automator, so I can't tell you all the details.
 
You could also use TextWrangler (free) or BBEdit to do it. It can do search and replace on multiple files/folders, even using Regular Expressions (RegEx) if you want.
 
Flux Harmonic said:
It took BBedit to do it, but it did it really well. Too bad the program's like 100 bucks.
That's odd, TextWrangler is basically BBEdit except for a few "pro" features for developers, but AFAIK the search & replace features are the same (I know TextWrangler can do multi-file searches and optionally use grep). What is it that BBEdit does for this that TextWrangler won't?
 
The thing that bbedit is able to do that textwrangler can't (as far as i can tell) is set up multiple conditions for replacing text. For the most part what I'm doing is deleting lines that contain certain text strings, and there are something like 15 of them. To do this, you need to use text factories, and although textwrangler can use them, only bbedit can create them.
 
Another alternative is MassReplaceIt, which I'm the developer of. Although it doesn't currently support regular expressions (that's likely to be added later in the year), it does support multiple search strings, searches can be saved, and it's freeware. I'm also open to suggestions, so if it lacks a feature you want, let me know and I can probably add it.

If you use it, you can delete text by entering the text in a search field, while leaving the corresponding replace field blank.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.