trivial bash solution to the problem
nicely commented simple bash one-liner (alternative solution)