Q:

Running several sed commands on same files simultaneously

To change all occurences of the string foo to bar in all files in a directory I use
sed -i -- 's/foo/bar/g' *

Found that here
But I also want to change NAME to name etc. I tried,
sed -i -- 's/foo/bar/g' * ;  sed -i -- 's/NAME/name/g' *
This creates new files. How can I get this command to rewrite the original file with foo replaced with bar and also NAME replaced with name and then there would be other replacements, without creating new files?

A:

You can give several expressions to sed in one invocation:
sed -e 'expr' -e 'expr' -e ...

In your case:
sed -e 's/foo/bar/g' -e 's/NAME/name/g'

The expressions will be applied to each line of input in succession, from left to right.

