View Single Post
Old April 4th, 2018, 07:06 PM   #6
halvar
Blocked!
 
Join Date: Jan 2008
Location: HH
Posts: 1,963
Thanks: 115,040
Thanked 32,801 Times in 1,955 Posts
halvar 100000+halvar 100000+halvar 100000+halvar 100000+halvar 100000+halvar 100000+halvar 100000+halvar 100000+halvar 100000+halvar 100000+halvar 100000+
Default

HTML Code:
for x in $(seq 1 148) do
means do the following command with the numbers from 1 to 148 (148 times)

This is because
Code:
seq 1 148
returns the numbers from 1 to 148. You can execute "seq 1 5" in Terminal to get the idea

$x is a placeholder for the current value.

Code:
curl -o $x.jpg http://online.pubhtml5.com/vfof/guzu/files/large/$x.jpg;
is one command which is terminated by ";"
The "-o $x.jpg" is an option meaning save this as 1.jpg, 2.jpg and so on.

A more simple example printing the numbers 3 to 5:
Code:
for foo in $(seq 3 5); do echo $foo; done;
Sometimes you need leading zeros:
Code:
for foo in $(seq -w 3 10); do echo $foo; done;
You can provide a list of names, but you have to spell them out:
Code:
for v in foo bar "foo bar"; do echo ${v}; done;
* If a value contains blanks it has to be quoted ("foo bar")
* Sometimes the placeholder has to be in curly braces ${v}

Just toy around a bit to get the hang of it. I am not a bash scripting expert myself, but I often find it rather useful. Here is a very good documentation: http://tldp.org/LDP/Bash-Beginners-Guide/html/
halvar is offline   Reply With Quote