I love Free Software!

Pages

Funny Quotes to Think

When you say "I wrote a program that crashed Windows", people just stare at You blankly and say "Hey, I got those with the system, for free"

-Torvalds, Linus(1995-03-08)-

Tuesday, December 15, 2009

Search and replace content of file in entire directory

How can I search and replace file contents??

Every editor will have an options to search and replace content of a file .When we require to search all files in a directory and replace with new string, we can use below command

perl -pi -e 's/<Search-string>/<Replace-String>/' *

For example If You want to replace windows with linux in all perl files under a directory, You can use this command

perl -pi -e 's/windows/linux/' *.pl

No comments:

Post a Comment