I am now studying linux command line and this question is in my head for almost a week but i think still i have not found optimal solution, question is next: i have file with is formatted in a bad way one word on each line:
SUSE FEDORA SUSE UBUNTU FEDORA 10.2 10 11.0 8.04 8 10.3 6.10 2006-12-07 2008-11-25 2008-06-19 2008-04-24 2007-11-08 2007-10-04 2006-10-26 2007-05-31 2007-10-18
as you see those are linux distros with version and release dates right formatting is next :
2008-11-25 SUSE 10.2 2008-06-19 FEDORA 10 2008-04-24 SUSE 11.0 ...
I believe there must be very simple way to sort this right, i mean with one line of commands, not to save in other file and then paste in other file.
Advertisement
Answer
I took a matching number of items from you post
SUSE FEDORA SUSE UBUNTU FEDORA 10.2 10 11.0 8.04 8 10.3 2006-12-07 2008-11-25 2008-06-19 2008-04-24 2007-11-08
This script will convert to 3 columns and reorder fields
pr -3t filename | awk '{print $3,$1,$2}' 2006-12-07 SUSE 10.2 2008-11-25 FEDORA 10 2008-06-19 SUSE 11.0 2008-04-24 UBUNTU 8.04 10.3 FEDORA 8