Indonesia Website Awards
Indonesia Website Awards

hello everyone, this time I want to share a way to replace strings in all files on Linux. Not long ago I had a case to change a word (in string form) which I have to do in all php files in my office project. It must be difficult if we don’t know the word we want to change is in any file and directory. Well, there is actually an easy way to do it. Immediately, without further ado, how to combine the find and sed commands on Linux. The steps are simple:

 

first, go to the main directory where all the files we want to find and we change the string

 

cd /path/your/directory

 

second, use the find and sed commands to change all strings in all files that contain these strings

 

find ./ -type f -exec sed -i 's/me/you/g' {} \;

 

The command will be something like this: “Find / Find all files that contain me strings then change all the strings to you

 

Also Read : Searching for Files Containing Certain Words in Linux

 

Yep, that’s a way to replace strings in all files on Linux that I can share. Hopefully this information is useful for all readers. Thank you ^^

Categories: Linux

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *