title: Grep error due to expanding variables with spaces
body: <p>I have a file called "<code>physics 1b.sh</code>". In bash, if I try</p>
  
  <pre><code>x="physics 1b"
  grep "string" "$x".sh
  </code></pre>
  
  <p>grep complains:</p>
  
  <pre><code>grep:  physics 1b: No such file or directory.
  </code></pre>
  
  <p>However, when I do</p>
  
  <pre><code>grep "string" physics\ 1b.sh 
  </code></pre>
  
  <p>It works fine. So I guess the problem is something to do with the variable not being expanded to include the backslash that grep needs to recognize the space. How do I get this to work?</p>
  
  <p>Using bash 3.2, mac os 10.6.</p>
  
  <p>Edit:<br>
  Never mind, the problem was that x was set to <code>" physics 1b"</code>, but when I did  <code>echo $x</code>  to check the contents, bash chopped off the spaces in the front so I couldn't tell that it was different. The first way above actually works.</p>