If you write a bash script that nobody else can understand, you're going to own that thing for the rest of your life too. Perl is really your answer here. They don't call it "the Swiss army chainsaw" ...