day macha
bash time saver: for loops

Just now I had a bunch a packages I wanted to install.  I was going to do install package_1, then install package_2, etc etc.  Instead:

for a in package_1 package_2; do install $a; done

Fairly simple, and I knew for each loops existed in bash—just never got around to making part of my console habit.

Edit: install {package_1,package_2} works as well, making sure there are no whitespaces.

Blog comments powered by Disqus