[ale] mass file modification

Keith Hopkins ale at hopnet.net
Sun Mar 30 01:04:53 EDT 2008


On 03/30/2008 10:38 AM, Jim Popovitch wrote:
> I need to update about 43k files and sed just won't cut it for this
> task.   What I need to do is replace 2 lines with 4 new ones, and the
> lines contain URLs (backslashes, brackets, etc.).  What I would like
> to do is put the new text in a file and pass it and the search text to
> some program that will modify all the files.   Any ideas on whats
> available to do that?
> 

Hey Jim

Why won't sed word for you?  Does it take too long?  or do you get something like the old "too many arguments on the command line" error?

I had the 2nd problem yesterday, and I worked around it with a short script + sed.  I was fortunate that the filenames were all date+time with a ":" separator.  It went something like:

#!/bin/bash
ls -1 |  cut -d: -f1 | sort -u | while read ; do
sed -i 's/this/that/' ${REPLY}*
done

basically giving a subset of the files for sed to process in each loop of the while.  My filenames, like "2008_02_28:14.15", did make easier to subdivide the lot.

--Keith


More information about the Ale mailing list