开发者

Edit files with template

开发者 https://www.devze.com 2023-01-30 08:45 出处:网络
I have a lot of files which consist of some string. I have to remove it from all of files. How can I do this faster? Any ideas, pre开发者_JAVA技巧fer python-script, for example.

I have a lot of files which consist of some string. I have to remove it from all of files. How can I do this faster? Any ideas, pre开发者_JAVA技巧fer python-script, for example. Thanks.


sed -i "s/YOUR_STRING//g" *

/* or */
for file in `grep YOUR_STRING -l *`; do sed -i "s/YOUR_STRING//g" $file; done

first method will blindly remove the YOUR_STRING for all files

second method probably will break if too many files matched

updated : is not a python solution, ping me if you dislike and will delete it


sed -ie "s/SEARCH/REPLACEMENT/g" *

http://www.grymoire.com/Unix/Sed.html

0

精彩评论

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