Skip to content

Instantly share code, notes, and snippets.

@z-------------
Last active August 29, 2015 13:57
Show Gist options
  • Save z-------------/9871747 to your computer and use it in GitHub Desktop.
Save z-------------/9871747 to your computer and use it in GitHub Desktop.
My first dive into the world of shell scripting...
#!/bin/bash
# download.sh <dir> <file1> <file2>...
tempDir="$1"
#make folder and cd to it
mkdir $tempDir
cd $tempDir
#make array of arguments
if [ "$#" -eq 0 ]; then
echo "No arguments provided"
else
args=( "$@" )
fi
#curl files
for (( i=1; i<=$(( ${#args[@]} * 2 )); i++ ))
do
if [ ${#args[$i]} -gt 0 ]; then
curl -O ${args[$i]}
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment