title: Prevent globbing after variable substitution
body: <p>What is the most elegant way to use shell variable (BASH) that contain characters reserved for globbing (filename completion) that trigger some unwanted substitutions? Here is the example:</p>
  
  <pre><code>for file in $(cat files); do
     command1 &lt; "$file"
     echo "$file"
  done
  </code></pre>
  
  <p>The file names contain characters like '[' or ']'. I have basically two ideas:</p>
  
  <p>1) Turn off globbing via set -f: I need it somewhere else</p>
  
  <p>2) Escape the file names in files: BASH complains about "file not found" when piping into stdin</p>
  
  <p>Thx for any suggestion</p>
  
  <p><em>Edit: The only answer missing is how to read from a file with name containing special characters used for globbing when the filename is in a shell variable "$file", e. g. command1 &lt; "$file".</em></p>