perl -p -i -e replace line with text containing symbol
<p>In a linux Vm, I am trying to change the second line of 50+ files.</p>

<p>I have used this command below successfully for strings without symbols. </p>

<pre><code>perl -p -i -e 's/.*/new_line / if $.==2' .
</code></pre>

<p>However now I am trying to add the new string  " # $new_line $ " using this command :</p>

<pre><code>perl -p -i -e 's/.*/# $Header$ / if $.==2' .
</code></pre>

<p>But getting the following error:</p>

<pre><code>Final $ should be \$ or $name at -e line 1, within string
syntax error at -e line 1, near "s/.*/# $Header$ /"
Execution of -e aborted due to compilation errors.
</code></pre>

<p>Any help is appreciated. Thank you in advance.</p>