开发者

Changing occurrences of one pattern to another

开发者 https://www.devze.com 2023-01-28 02:19 出处:网络
grep -R \\\"\\/web * gives me some occurrences which i want to change to \\\"\\$\\/web How can I do th开发者_开发技巧is?Command-line: sed -i \'s/\"\\/web/\"$\\/web/g\' FILENAME, or omit -i and FILENA

grep -R \"\/web * gives me some occurrences which i want to change to \"\$\/web

How can I do th开发者_开发技巧is?


Command-line: sed -i 's/"\/web/"$\/web/g' FILENAME, or omit -i and FILENAME if piping input.

Take care when doing it though - it might be a good idea to run without -i first, and then with it if you are sure that the results are exactly what you want.

For multiple files: find . -type f -exec sed -i 's/"\/web/"$\/web/g' {} \;


With GNU sed

sed -r 's|"(/web)|"$\1|g' *

If your satisfied with the output, change sed -r to sed -ri to do an in-place edit


In vim:

:set hidden
:args *
:argdo %s/"web/"$web/g
:wqa
0

精彩评论

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