Tech Support Guy banner
Status
Not open for further replies.
1 - 3 of 3 Posts

·
Registered
Joined
·
159 Posts
Discussion Starter · #1 ·
Hey guys im having some trouble completing a sorting job on one of my files( the data is fake its just so I can test out how to do it)

William Donald 960WaydrColoradoSpringsCO80920 DesertCamoBPProd77778 719-689-9980
Mary Whitmore 1001StatonlnColoradoSpringsCO80920 BabyBlueBPProd77765 719-456-5000
Diego Torres 2360SanteFeBuenosAiresArgentina BlackRedBPProd77722 +54-4000-6800
Sven Ericsson 2953BeitstolenBeitstolenNorway BlackBPProd77721 +47-61-35-30-00


Anyways I want to sort it by last name so basically in this case sven ericsson should be on top of whitmore. However I have tried several different sort options and can never get it to work... IM completely lost.

Could someone show me how I would do this?
 

·
Registered
Joined
·
534 Posts
I used the following command to get the results below.
$ sort -r +2 test.txt
I think this is the right result ????

William Donald 960WaydrColoradoSpringsCO80920 DesertCamoBPProd77778 719-689-9980
Sven Ericsson 2953BeitstolenBeitstolenNorway BlackBPProd77721 +47-61-35-30-00
Diego Torres 2360SanteFeBuenosAiresArgentina BlackRedBPProd77722 +54-4000-6800
Mary Whitmore 1001StatonlnColoradoSpringsCO80920 BabyBlueBPProd77765 719-456-5000
 

·
Registered
Joined
·
21,398 Posts
Using the file test.txt containing your data on Ubuntu 7.10 Gutsy Gibbon:

$ cat test.txt | sort -k2
will print out:
William Donald 960WaydrColoradoSpringsCO80920 DesertCamoBPProd77778 719-689-9980
Sven Ericsson 2953BeitstolenBeitstolenNorway BlackBPProd77721 +47-61-35-30-00
Diego Torres 2360SanteFeBuenosAiresArgentina BlackRedBPProd77722 +54-4000-6800
Mary Whitmore 1001StatonlnColoradoSpringsCO80920 BabyBlueBPProd77765 719-456-5000

-- Tom
 
1 - 3 of 3 Posts
Status
Not open for further replies.
Top