Michael Barton wrote:

> I'm betting there is a Unix command to do a batch search and replace  
> of one string with another in all text files in a directory.
> 
> But I don't know what it is.

GNU sed has the following extension:

       -i[SUFFIX], --in-place[=SUFFIX]

              edit files in place (makes backup if extension supplied)

If you use that option, you can pass multiple filenames, and sed will
process each one separately, e.g.:

        sed -i -e 's/old/new/g' *.txt

Without the -i script, the source files will be concatenated and
processed as a single stream.

If you don't have GNU sed, you need a loop, e.g.:

        for file in *.txt ; do
            sed 's/.../.../g' "$file" > "$file".tmp && mv -f "$file".tmp "$file"
        done

-- 
Glynn Clements <[EMAIL PROTECTED]>
_______________________________________________
grass-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-dev

Reply via email to