Iterate Over Files in Bash

Sometimes you need to whip up a dirty bash script to process through some text. I needed to iterate over my database log files that I wrote about from my last post and then output the result to a new file. I wanted the output files to have a different extension, but I wasn't sure how to get just the filename from bash, fortunately this post helped.


for logfile in *.log

fn=${logfile%.*} #cut extension

echo making $
egrep '\#\ collect|\:\=' $logfile > $ 


If you made it this far, you should follow me on Twitter.


Want to test-drive Bitcoin without any risk? Check out my bitcoin wallet Coinbolt. It includes test coins for free.

comments powered by Disqus