title: Line deleting trouble in bash: passing user-input to sed vs to grep?
body: <p>Bashing trouble in MSYS: The following simple function should delete all lines that match user-input string <code>$kwd</code>.</p>
  
  
  
  <pre><code>function delnote () {
     read kwd
     sed -e "/$kwd/d" -i ~/notes.txt
  }
  </code></pre>
  
  <p>Instead, I keep getting <em>"sed -e expression #1, char 0: no previous regular expression"</em> errors. Why?</p>
  
  <p>I'm new to both bash and sed (and MSYS), so I'm not sure whether this is an issue of passing variables to sed or using quotes the wrong way (I've effortlessly tried replacing <code>""</code> with <code>''</code> in many variations). I tried using <a href="https://stackoverflow.com/questions/4108850/passing-bash-arguments-into-sed-to-delete-lines">the function provided here</a> instead of my own, but still got the same error. </p>
  
  <p>In case this is an issue of misplacing quotes, then what's the difference between how sed and grep handle user input in bash? (As opposed to sed, using <code>'"$*"'</code> in a grep function does work.)</p>
  
  <p>Thanks for any help and explanations!</p>