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.