9

I want to download a number of files which are as follows:

http://example.com/directory/file1.txt http://example.com/directory/file2.txt http://example.com/directory/file3.txt http://example.com/directory/file4.txt . . http://example.com/directory/file199.txt http://example.com/directory/file200.txt 

Can anyone help me with it using shell scripting? Here is what I'm using but it is downloading only the first file.

for i in {1..200} do exec wget http://example.com/directory/file$i.txt; done 

2 Answers 2

10
wget http://example.com/directory/file{1..200}.txt 

should do it. That expands to wget http://example.com/directory/file1.txt http://example.com/directory/file2.txt ....

Alternatively, your current code should work fine if you remove the call to exec, which is unnecessary and doesn't do what you seem to think it does.

Sign up to request clarification or add additional context in comments.

Comments

2

To download a list of files you can use wget -i <file> where is a file name with a list of url to download.

For more details you can review the help page: man wget

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.