title: "No such file or directory" on simple bash redirection
body: <p>Here is some code of mine:</p>
  
  <pre><code>gzip -c $path &gt; /var/www/wiki/backup/$now/$file.gz
  </code></pre>
  
  <p>I'm gzipping the contents of <code>$path</code> (the path to a directory), and then sending the compressed file to <code>/var/www/wiki/backup/$now/$file.gz</code>. <code>$now</code> contains a directory name, <code>$file</code> is the name I want to write the compressed file to.</p>
  
  <p>However, on running the program, I get this error:</p>
  
  <pre><code>backup.sh: line 20: /var/www/wiki/backup/Sunday/extensions.gz: No such file or directory
                                           ^$now    ^$file
  </code></pre>
  
  <p>(line 20 is the line given above)</p>
  
  <p>Why is the program breaking? I know <code>Sunday/extensions.gz</code> doesn't exist (although Sunday does), that's why I'm asking you to write to it!</p>
  
  <p>Full program code:</p>
  
  <pre>
  #!/bin/bash
  
  now=$(date +"%A")
  mkdir -p /var/www/wiki/backups/$now
  
  databases=(bmshared brickimedia_meta brickimedia_en brickimedia_customs)
  locations=("/var/www/wiki/skins" "/var/www/wiki/images" "/var/www/wiki/")
  
  for db in ${databases[*]}
  do
  #command with passwords and shoodle
  :
  done
  
  for path in ${locations[*]}
  do
  #echo "" > var/www/wiki/backup/$now/$file.gz
  file=`echo $path | cut -d/ -f5`
  echo $path
  gzip -c $path > /var/www/wiki/backup/$now/$file.gz
  done
  </pre>