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
精彩评论