sd
sd copied to clipboard
Replace only if the string is found in a certain context
How can I replace foo with bar only if there is a baz later on the same line, For example, in sed the command looks like:
sed -i 's/foo\(.*baz\)/bar\1/' file
Or, how can I replace foo with bar only if foo is found on the 3d field of the input file