开发者

Changing occurrences of one pattern to another

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜