Skip to content

Instantly share code, notes, and snippets.

@pjanuario
Last active August 29, 2015 14:28
Show Gist options
  • Save pjanuario/20a367a6b07317adcebc to your computer and use it in GitHub Desktop.
Save pjanuario/20a367a6b07317adcebc to your computer and use it in GitHub Desktop.
Bash script to download files from a comma separated source file.
mkdir -p /tmp/downloaded_files
while IFS='' read -r line || [[ -n "$line" ]]; do
#echo "Text read from file: $line"
filename=$(echo $line | cut -d "," -f 1)
url=$(echo $line | cut -d "," -f 2)
echo "url: $url filename: $filename"
curl $url -o "/tmp/downloaded_files/$filename"
done < "$1"
echo "files are in /tmp/downloaded_files"
@pjanuario
Copy link
Author

  • Download the script
  • Execute (on terminal to make it executable)
    $ chmod +x download_files.sh
  • Run script using
    $ ./download_files.sh source.file

NOTE: The file need to be in the following format:

filename,url
filename,url

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment