title: creating a file downloading script with checksum verification
body: <p>I want to create a shellscript that reads files from a .diz file, where information about various source files are stored, that are needed to compile a certain piece of software (imagemagick in this case). i am using Mac OSX Leopard 10.5 for this examples. </p>
  
  <p>Basically i want to have an easy way to maintain these .diz files that hold the information for up-to-date source packages. i would just need to update these .diz files with urls, version information and file checksums.</p>
  
  <p>Example line:</p>
  
  <pre><code>libpng:1.2.42:libpng-1.2.42.tar.bz2?use_mirror=biznetnetworks:http://downloads.sourceforge.net/project/libpng/00-libpng-stable/1.2.42/libpng-1.2.42.tar.bz2?use_mirror=biznetnetworks:9a5cbe9798927fdf528f3186a8840ebe
  </code></pre>
  
  <p>script part:</p>
  
  <pre><code>while IFS=: read app version file url md5
  do 
    echo "Downloading $app Version: $version"
    curl -L -v -O $url 2&gt;&gt; logfile.txt
    $calculated_md5=`/sbin/md5 $file | /usr/bin/cut -f 2 -d "="`
    echo $calculated_md5    
  done &lt; "files.diz"
  </code></pre>
  
  <p>Actually I have more than just one question concerning this.</p>
  
  <ol>
  <li>how to calculate and compare the checksums the best? i wanted to store md5 checksums in the .diz file and compare it with string comparison with "cut"ting out the string</li>
  <li>is there a way to tell curl another filename to save to? (in my case the filename gets ugly libpng-1.2.42.tar.bz2?use_mirror=biznetnetworks)</li>
  <li>i seem to have issues with the backticks that should direct the output of the piped md5 and cut into the variable $calculated_md5. is the syntax wrong?</li>
  </ol>
  
  <p>Thanks!</p>