How to replace a string in a file only if the line containing it does not also contain a specific string using Bash?
<p>I would like to replace all instances of <code>target</code> with <code>replace</code> in the following file.csv using Bash, but only if the line containing it does not also contain the string <code>skipline</code>:</p>

<p>file.csv:</p>

<pre><code>abc,abc,keepline,target,abc,abc
abc,abc,skipline,target,abc,abc
</code></pre>

<p>Desired output:</p>

<pre><code>abc,abc,keepline,replace,abc,abc
abc,abc,skipline,target,abc,abc
</code></pre>

<p>I am attempting to use <code>sed</code>:</p>

<pre><code>sed 's/target/replace' file.csv &gt; newfile.csv
</code></pre>

<p>How can I include logic to check each line for the string <code>skipline</code>?</p>