Find and Replace Text Within Multiple Files in Linux – Avoid RSI

After updating 100+ pages manually, I realized that I had neglected to add “index.php” to the end of certain links. Usually this would be fine, but the links in question are opened in Shadowbox, which will fail on pretty, “index.php”-less links.

I was able to fix this on the server in 5 seconds with find+perl:

find . -name 'FILE_NAME.EXTENSION' | xargs perl -pi -e 's/FIND/REPLACE/g'

Where FILE_NAME is the name of the files to be searched in (can be ‘*’) and EXTENSION is the filetype (can be ‘*’). FIND is the text to be searched, and REPLACE is a replacement string.

Phew!

Like this post? Move it on along with:

email Email | delicious delicious | digg Digg | Tweet this post Tweet | reddit Reddit | newsvine Newsvine | furl Furl | google Google | StumbleUpon Stumble | Hao Hao HaoHao


Trackback:

Comments: 0 | Comments Feed


Scroll to top

Related posts:

  1. Strip /uXXXX From String and Replace it With the Correct Unicode Character I discovered '/uXXXX' appearing where pretty unicode characters should be within my strings. The strings were to be compared to ... other strings, which would have the proper unicode characters, so I had to replace the '/uXXXX' in my strings. I couldn't find a class to do this, but found enough information to understand what needed to be done. The...
  2. Perl Script to Insert DBpedia Infobox Data into a MySQL Database This script parses out the Wikipedia page, DBPedia Infobox Predicate and Infobox subject, and inserts them into a MySQL table. I thought I'd share it with The Internet in case someone else wanted to work with DBPedia infobox data in the same way....
  3. Roy’s Wordpress Cumulus Tag Cloud in Rapidweaver! I’ve managed to find a way to integrate Roy’s awesome tag cloud plugin with Rapidweaver’s blog page....

Comments (1)Trackback

One Response to “Find and Replace Text Within Multiple Files in Linux – Avoid RSI”