FlipsideReality Once upon a time, in a land far far away…

18Jul/080

*nix bash while read line do – to proccess all files in a direcotry tree. because i keep forgetting….

I keep forgetting the syntx for while read.

essentially, you pipe a bunch of lines into it, and then it'll process each line e.g.:

$find ~/video -iname '*avi' -or -iname '*mpeg' | while read movie ; do
mencoder [encoding options...] "$movie" -o ~/converted/`basename
"$movie"` ; done

Yay.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
Tagged as: , No Comments