FW: [Gllug] Awk Sed

harry postituk at yahoo.com
Fri Dec 7 07:39:52 UTC 2001


Hi all

Having had a little play I came up with the following to run through a
directory and change text in only the files found.

Put this in a shell script called harrysed
#! /bin/sh
for file in $(ls  $3);do

echo $file
sed -e 's/'$1'/'$2'/g' $file > '$fileff'; more '$fileff' > $file; rm
 '$fileff'

done

Run like this

>$./harrysed a b *.txt

This will go through the current directory and substitute all the a's for b's
only where the file has the .txt extension. Again it has not been tested much
but it seems to work Ok. Any comments warmly welcomed.

Harry

-------------------------------------------------------

-- 

Harry Jackson

::::::::::::::
20
::::::::::::::
"Fanatacism consists in redoubling your effort when you have forgotten your 
aim."
George Santayana

-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list