WalaWiki content from p1k3.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

40 lines
1.0 KiB

BashTricks. I always forget how to do this, and I'm sick of looking it up for that once every two months when I need it.
* [http://partmaps.org/era/unix/award.html useless use of cat award]
* http://db.ilug-bom.org.in/Documentation/abs-guide/loops1.html
* http://anton.lr2.com/archives/2005/03/24/using-a-bash-for-loop-to-wget/ - Slurp up some of this info.
for arg in [list]
do
command...
done
Don't feel like you have to string this all together on one line when you're doing it in an interactive shell. Just hit enter after each line.
To steal an example:
for planet in "Mercury Venus Earth Mars Jupiter Saturn Uranus Neptune Pluto"
do
echo $planet
done
Note that [list] can be the output of a given program - just use backticks, like so:
for doc in `ls *.doc`
do
file $doc
done
A real world example:
for release in `ls`
do
iconv -f iso-8859-1 -t utf-8 ./$release ../converted/$release.html
done
You probably should use globs instead, though:
for release in *
do
foo ./$release
done