title: Replacing a string in nth line a file
body: <p>Hi need to replace a string in file <strong>only in nth line</strong> of file</p>
  
  <p>file1</p>
  
  <pre><code>  hi this is line 1
    hi this is line 2
    hi this is line 3
    hi this is line 4
  </code></pre>
  
  <p>I need to replace 'hi' only in line 2</p>
  
  <p>experted as below </p>
  
  <pre><code>  hi this is line 1
    Hello this is line 2
    hi this is line 3
    hi this is line 4
  </code></pre>
  
  <p>I tried by creating a temp file </p>
  
  <pre><code>  sed -n 2p  file1 &gt; temp1
    perl -pi -e 's/hi/Hello/g' temp1  \\I tried to replace temp1 with line 2 in file1
    sed -i  '2d' file1   \\after this I failed to insert temp1 as a 2nd line in file1
  </code></pre>
  
  <p>Help me to replace a string in file in Nth line(without temp file is preferred.. ).</p>
  
  <p>Thank you</p>