title: OSX: Running a shell script?
body: <p>I'm new to shell scripts, but I'm trying to run the following script, to download all the .png files from an xml.</p>
  
  <p>Is this the correct way?</p>
  
  <pre><code>bash myScript.sh
  </code></pre>
  
  <p>Inside my script I have the following:</p>
  
  <pre><code>#!/bin/bash
  URL='https://theurlwiththexml.com'
  i=0
  for u in $(curl -s "$URL" |
             grep png | 
             sed -E 's/.*&lt;ImageStuff&gt;(.+)&lt;\/ImageStuff&gt;/\1/'); do
      curl -s "$u" -o $i.png
      (( i++ ))
  done
  </code></pre>
  
  <p>The xml on the page looks the following way:</p>
  
  <pre><code>&lt;ListBucketResult xmlns="http://url1.com"&gt;
    &lt;Name&gt;imagesToUse&lt;/Name&gt;
  &lt;Prefix/&gt;
  &lt;Marker/&gt;
  &lt;IsTruncated&gt;false&lt;/IsTruncated&gt;
  &lt;Contents&gt;
    &lt;ImageStuff&gt;imagetodownload.png&lt;/ImageStuff&gt;
    &lt;Size&gt;17293&lt;/Size&gt;
  &lt;/Contents&gt;
  </code></pre>