I will admit that this question does seem to be a bit in the gray area between StackOverflow (bash programming) and SuperUser (shell tricks) - though it seems at least slightly off-topic for ServerFault.
In any case, this question collected a number of answers on all sites.
Should I cross-post my own answer? Is there a policy on the issue of answers to cross-posted questions?
Is there a way to merge those answers, so that they are all in the same place? Right now I can only think of adding comments with links in each one...
Should habitual simultaneous cross-posters be penalized by e.g. downvoting?