Thursday, March 12, 2009

My new cmdline friend

While I still profess my love for xargs, I must admit I've been using something else quite a bit lately. In my search for a way to more easily do lambda style operations from the command line, I was directed to while. while has not only allowed me to use the variable I'm iterating over more easier, it has also allowed me to have multi-statement commands in my loops.

Here is a sample of what I'm now able to easily do:

find -maxdepth 1 -type d | while read x; do echo '>>> Doing ' $x; ( cd "$x"; printf "ID: "; hg id; hg purge --all; ); done

No comments: