Wednesday, May 27, 2009

Stupid BASH Trick 01

I have to look this up all the time, if you are BASH scripting and you want to do something with each file in the current directory try something like this:
#!/bin/bash
for i in $( ls ); do
echo item: $i
done

Or the one liner
for i in $( ls ); do echo item: $i; done
There, maybe next time I will not have to look as hard. :-P

No comments:

Post a Comment