I've never used commands in terminal like this before but I know its possible. How would I for instance write:
for (int i = 0; i <=1000; i++) { echo "http://example.com/%i.jpg",i }
1) Syntax:Syntax of for loop using in and list of values is shown below. This for loop contains a number of variables in the list and will execute for each item in the list. For example, if there are 10 variables in the list, then loop will execute ten times and value will be stored in varname.
The basic syntax of a for loop is: for <variable name> in <a list of items>;do <some command> $<variable name>;done; The variable name will be the variable you specify in the do section and will contain the item in the loop that you're on.
The commands you enter during a session are saved so you can repeat a previously used command without retyping it. In the Terminal app on your Mac, press the Up Arrow key. The last command you entered appears on the command line. Continue pressing the Up Arrow key until you see the command you want, then press Return.
The default shell on OS X is bash. You could write this:
for i in {1..100}; do echo http://www.example.com/${i}.jpg; done
Here is a link to the reference manual of bash concerning loop constructs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With