There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
Linux and Unix
Tag Cloud
access acer asus bios bsod computer crash driver drivers error ethernet excel freeze gaming google gpu graphics hard drive hardware hdmi internet laptop malware memory modem monitor motherboard network printer problem ram registry repair router security slow software sound trojan usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless
Search
Search for:
Tech Support Guy Forums > Operating Systems > Linux and Unix >
Sort command help

Reply  
Thread Tools
xMikex's Avatar
Senior Member with 159 posts.
 
Join Date: Nov 2005
Experience: Intermediate
07-Mar-2008, 02:52 PM #1
Sort command help
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?
__________________
Programmer
C++, C#, Flex, Assembly
bkdc's Avatar
Senior Member with 524 posts.
 
Join Date: Apr 2003
Location: Tampa, Flordia USA
Experience: Advanced Dummy
07-Mar-2008, 09:53 PM #2
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
__________________
RLU - 461216

If you talk, you repeat what you already know. If you listen, you learn.
lotuseclat79's Avatar
Distinguished Member with 21,345 posts.
 
Join Date: Sep 2003
Location: -71.45091, 42.27841
08-Mar-2008, 11:40 AM #3
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
__________________
The independence created by philosophical insight is - in my opinion - the mark of distinction
between a mere artisan or specialist and a real seeker after truth. - Einstein 1944
Imagination is more important than knowledge. - Einstein
Reply

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
Thread Tools



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 05:10 AM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.