Incidentally, you can do a lot of these command-line exercises almost as succinctly with perl one-liners, which is one reason why perl was so popular among Unix-heads back in the days.