Tutorials, Guides, Tips, and Tricks from Everyday Experiences

You can count up or down easily in the terminal using the command seq. Combine this with a for loop and you have a really quick and easy way to count from x to y for the variable i. For example, if I wanted to download all images that have been numbered step1.png, step2.png, step3.png, …, step20.png I could use the following command to download them:

for i in $(seq 1 20); do wget http://website.com/images/step$i.png; done

Mac OS Users:
Unfortunately, ‘seq’ isn’t included on Mac OS, so you’ll need to use the ‘jot’ program or cleverly use the ‘jot’ program in a script to mimic the ‘seq’ command and syntax like so (thanks to Fredrick Rodland for this one):

If you’re a Mac user, I would recommend that you copy and save this to a file, save it as seq, make it executable with ‘chmod +x seq’, and finally copy it to your /usr/local/bin directory with ‘cp seq /usr/local/bin’.

Related

Feel free to
donate if this post prevented any headaches! Another way to show your appreciation is to take a gander at these relative ads that you may be interested in: