sd icon indicating copy to clipboard operation
sd copied to clipboard

Replace only if the string is found in a certain context

Open blueray453 opened this issue 4 years ago • 0 comments

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

blueray453 avatar Sep 07 '21 08:09 blueray453