Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the best tool to find and replace regular expressions over multiple files?

Preferably free tools if possible.

Also, the option of searching for multiple regular expressions and each replacing with different strings would be a bonus.

like image 934
Umber Ferrule Avatar asked Sep 19 '08 14:09

Umber Ferrule


People also ask

How do I find and replace in multiple files?

Remove all the files you don't want to edit by selecting them and pressing DEL, then right-click the remaining files and choose Open all. Now go to Search > Replace or press CTRL+H, which will launch the Replace menu. Here you'll find an option to Replace All in All Opened Documents.

How do I find and replace in multiple files in Notepad++?

Open the text file in Notepad++. In the top menu bar, click Search and select Replace. In the Replace window, on the Replace tab, enter the text you want to find and the text you want to use as a replacement. See our using search and replace and advanced options for further information and help.

How do you replace a string that occurs multiple times in multiple files inside a directory?

s/search/replace/g — this is the substitution command. The s stands for substitute (i.e. replace), the g instructs the command to replace all occurrences.


1 Answers

Perl.

Seriously, it makes sysadmin stuff so much easier. Here's an example:

perl -pi -e 's/something/somethingelse/g' *.log 
like image 199
Alex Fort Avatar answered Oct 12 '22 15:10

Alex Fort