Friday, 9 August 2013

How to perform the reverse of `xargs`?

How to perform the reverse of `xargs`?

I have a list of numbers that I want to reverse.
They are already sorted.
35 53 102 342
I want this:
342 102 53 35
So I thought of this:
echo $NUMBERS | ??? | tac | xargs
What's the ???
It should turn a space separated list into a line separated list.
I'd like to avoid having to set IFS.
Maybe I can use bash arrays, but I was hoping there's a command whose
purpose in life is to do the opposite of xargs (maybe xargs is more than a
one trick pony as well!!)

No comments:

Post a Comment