Answer the question
In order to leave comments, you need to log in
How to execute a set of regular expressions on multiple files?
There is a set of regular expressions (~100 pieces) to perform a replacement in the text. You need to perform these replacements in all files matching the given masks. What is the easiest way to do this?
This is the task of project migration: the API has changed and you need to replace old calls with new ones in all project files. It is desirable so that any other user can use it.
Answer the question
In order to leave comments, you need to log in
The text editor is not specified and they have different capabilities.
Therefore (for me) the easiest way is to replace with a bunch of GNU tools: find (search for files by mask and start processes on them) + sed (actually, replaces the text of a file with a regular expression)
Before executing, test on single files and save the original version of the files.
find /path/to/project -type f -name "*.php" -exec sed -i 's/регулярка/новыйтекст/g' {} \;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question