Categories

Our Sponsors

Command Line Search and Replace

So you want to change some text in many unix files.

Try the following.

perl -pi -e ‘s/find/replace/g’ *.txt

or to script it out. Find the TEXT in regular files and replace with NEWTEXT

for file in `find ./ -type f -exec grep -l TEXT {} \;` do perl -pi -e ‘s/TEXT/NEWTEXT/g’ $file done

[...]

Share
Get Adobe Flash playerPlugin by wpburn.com wordpress themes