Alaa Al-ashari
Alaa Al-ashari

Reputation: 11

wget download and outout based on list

I have list of names and URLs like this:

first name
http://somewhere:port/pat/of/file.mp4
second name
http://somewhere:port/pat/of/file2.mp4
third name 
enter code here
http://somewhere:port/pat/of/file3.mp4

How can we get these files with wget, and name each file with the line before the URL?

i.e.: third name would contain data from http://somewhere:port/pat/of/file3.mp4

Thank you in Advance

Upvotes: 1

Views: 36

Answers (1)

Romeo Ninov
Romeo Ninov

Reputation: 7225

You can try something like:

exec 4< input_file
while read name <&4 ; do
 read url <&4
 wget -O "$name" %url
done

If filenames contain special characters, space, etc is good to have them in file in double quotes.

Upvotes: 1

Related Questions