Home > front end >  Script to download a list with wget in bash
Script to download a list with wget in bash

Time:09-17

I have a list of download links (list.txt):

https://web.com/file1.zip
https://web.com/file2.zip
https://web.com/file3.zip

and so on up to 100...

I'm trying to build a script that will download my files using wget, but the emphasis here is that every time one file is downloaded, the ls command will be executed. This is what my long script looks like, but I want to shorten it and make it smarter, and instead of manually writing line by line each time, that the script is read line by line and downloaded in order with the execution of the ls command in each download when the first one to turn has finished

wget https://web.com/file1.zip && ls ; wget https://web.com/file2.zip && ls ; wget https://web.com/file3.zip && ls ;

And so on up to 100

CodePudding user response:

use forloop to squash your similar wget commands.

for i in {1..100}
do
  wget https://web.com/file"$i".zip && ls
done

Please be aware of that this is bash shell style. You can also write other shell style.

CodePudding user response:

#!/bin/bash
for iurl in $(cat list.txt); do
    wget $iurl && ls
done
  •  Tags:  
  • bash
  • Related