title: Bash script for downloading files with Curl
body: <p>I'm trying to knock together a little batch script for downloading files, that takes a URL as its first parameter and a local filename as its second parameter.  In testing I've learned that its tripping up on spaces in the output filename, so I've tried using sed to escape them, but its not working.</p>
  
  <pre><code>#!/bin/bash
  clear
  echo Downloading $1
  echo
  filename=`sed -e "s/ /\\\ /g" $2`
  echo $filename
  echo eval curl -# -C - -o $filename $1
  </code></pre>
  
  <p>but I get the message</p>
  
  <blockquote>
    <p>sed: outfile.txt: No such file or directory</p>
  </blockquote>
  
  <p>which suggests its trying to load the output file as input to sed instead of treating the output filename as a string literal.</p>
  
  <p>What would be the correct syntax here?</p>