Last active
December 17, 2019 01:43
-
-
Save cosmoscalibur/16e77e0995f4416fc09b7944ac53e064 to your computer and use it in GitHub Desktop.
Download files from URL specified in plain text files (one per file) and save with the same name of the origin file. https://askubuntu.com/questions/1196228/wget-from-file-and-save-as-acording-to-file-name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env bash | |
# usage: bash wget_custom.sh | |
# Put this file in the same directory of `frm` files with unique URL to download. | |
# Downloades file has the same name of `frm` file but the extension is `txt`. | |
# Answer to AskUbuntu question: https://askubuntu.com/questions/1196228/wget-from-file-and-save-as-acording-to-file-name | |
SAVEIFS=$IFS | |
IFS=$'\n' | |
files=$(ls -1 *.frm) | |
for file in ${files[@]}; do | |
downloaded_file=$(echo $file | sed 's/\.frm/.txt/') | |
url_file=$(more $file) | |
wget $url_file -O $downloaded_file | |
done | |
IFS=$SAVEIFS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment