title: How can I replace a specific line of a file in bash script?
body: <p>I have a file inside the one directory, I want to replace one specific line with another line.</p>
  
  <p>In my case the line is - "password   requisite  pam_pwquality.so"
  and I want to make it as</p>
  
  <p>"#password  requisite  pam_pwquality.so".</p>
  
  <p>I tried like this:</p>
  
  <pre><code> cat test1 | while read line
      do
         if grep -q "$str" test1; then
              echo "found"
              sed -i -e "s/${str}/${str1}/g" test1
  
         fi
  </code></pre>
  
  <p>but it is showing multiple found statements but I am having only one copy of this line.</p>