http://www.perlmonks.org?node_id=710128


in reply to Re: Five Ways to Reverse a String of Words (C#, Perl 5, Perl 6, Ruby, Haskell)
in thread Five Ways to Reverse a String of Words (C#, Perl 5, Perl 6, Ruby, Haskell)

Here's another awk solution (different strategy, and slightly shorter when compacted - Update: this reverses every line, and if your's did the same, i.e, without the END block, it would still be shorter than this...oh well):
#!/bin/awk -f { for (i=1; i<=NF/2; i++) { t=$i $i = $(NF-i+1) $(NF-i+1)=t } print }