grep regex multiple replacements
I will probably have done it "manually" by the time I get an answer for this.
I have two variables (varA, varB) I want to replace with (a, b) respectively, this currently requires two separate find and replaces.
with regex grep I know how to do two separate searches using v开发者_高级运维arA | varB
but there is no replace function that will similarly do a respective replacement
unless you know better? thanks for any insight
grep is used for searching pattern in a given input. You should use sed for text replacements. For multiple replacements in single sed command just use it like this:
sed -e 's/varA/foo/g' -e 's/varB/bar/g' file.txt
精彩评论