开发者

Search and replace text in all files of a linux directory

开发者 https://www.devze.com 2023-01-23 22:21 出处:网络
I have a website directory where I need to change all hardcoded links from one d开发者_如何转开发omain to another.Looking for a single (grep? sed?) bash command that will allow me to change all occurr

I have a website directory where I need to change all hardcoded links from one d开发者_如何转开发omain to another. Looking for a single (grep? sed?) bash command that will allow me to change all occurrences of text in all files in the directory?


The following will do it:

sed -i 's/old_link/new_link/g' file...

Don't forget to escape any slashes, dots, and any other regex special chars in the link addresses with a backslash.


Also, try:

perl -p -i -e <regex> <folder>
0

精彩评论

暂无评论...
验证码 换一张
取 消