How do I search/and replace like this using sed or another tool
FOO => BAR
Foo => Bar
foo => bar
That is: Look for foo regardless of case, and replace with the same case pattern.
One "solution" is to run sed once for each case-sensitive pattern but it becomes more work.
sed -i -r -e 's/FOO/BAR/g' -e 's/Foo/Bar/g' -e 's/foo/bar/g' file
– clement Jul 23 '14 at 13:59