Mourning the loss of our friend, WhitPhil.
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 audio blue screen boot bsod connection crash dell desktop driver dvd email error excel excel 2003 firefox hard drive hardware hijackthis internet keyboard laptop malware monitor motherboard network networking outlook problem processor ram recovery router screen slow sound spyware tdlwsp.dll trojan upgrade vba video virus vista vundo windows windows 7 windows vista windows xp wireless
Search
Search for:
Tech Support Guy Forums > Operating Systems > Linux and Unix >
Sort command help

Tip: Click here to scan for System Errors and Optimize PC performance
[ Sponsored Link ]

Closed Thread
 
Thread Tools
xMikex's Avatar
Senior Member with 157 posts.
 
Join Date: Nov 2005
Experience: Intermediate
07-Mar-2008, 01: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?
__________________
My Rig
Intel Pentium 4, 2866MHz
1gb RAM
Asus P4C800 Deluxe
eVGA GeForce 6800GS 256mb
420w Power supply(Name escapes me)


I used to be 'with it', then they changed
what 'it' was. Now what I'm 'with' isn't 'it',
and what's 'it' seems weird and scary to me
-.-Jone of the TSG Forums
bkdc's Avatar
Senior Member with 526 posts.
 
Join Date: Apr 2003
Location: Tampa, Flordia USA
Experience: Advanced Dummy
07-Mar-2008, 08: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 14,988 posts.
 
Join Date: Sep 2003
Location: -71.45091, 42.27841
08-Mar-2008, 10: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
Closed Thread Bookmark and Share

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.

Smart Search

Find your solution!



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


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -5. The time now is 08:45 PM.
Copyright © 1996 - 2009 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.
Powered by Cermak Technologies, Inc.