Thursday, February 18, 2010

Replace string in 'n' files in one shot!

Change a pattern in all the files in one go!

#!/bin/sh

for file in $(grep -il "devdb" *.sql)

do

sed -e "s/devdb/testdb/g" $file > /tmp/tempfile.tmp

mv /tmp/tempfile.tmp $file

done

No comments: