Every two weeks I send out a newsletter containing lots of interesting stuff for the modern PHP developer. You can expect quick tips, links to interesting tutorials, opinions and packages. Want to learn the cool stuff? Then sign up now!

The Bash For Loop, The First Step in Automation on Linux

In a post on his site Mattias Geniar shares how to write for loops in Bash.

Let me first start by saying something embarrassing. For the first 4 or 5 years of my Linux career — which is nearing 10 years of professional experience — I never used loops in Bash scripts. Or at the command line.

The thing is, I was a very fast mouse-clicker. And a very fast copy/paster. And a good search & replacer in vim and other text editors. Quite often, that got me to a working solution faster than working out the quirky syntax, testing, bugfixing, … of loops in Bash.

And, to be completely honest, if you’re managing just a couple of servers, I think you can get away with not using loops in Bash. But, once you master it, you’ll wonder why you haven’t learned Bash for-loops sooner.


Freek Van der Herten is a partner and developer at Spatie, an Antwerp based company that specializes in creating web apps with Laravel. After hours he writes about modern PHP and Laravel on this blog. When not coding he’s probably rehearsing with his kraut rock band.