Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 07-15-2005, 01:51 AM   #1
LQ Newbie
Registered: Apr 2005
Location: India
Distribution: Redhat 9
Posts: 17

Rep: Reputation: 0
shell scripting


can u help me in sorting a file.

let a file has 5 fields, i have to sort it with respect to the 2nd field. can u tell me the command for this.

thanks in advance.....
Old 07-15-2005, 02:24 AM   #2
Registered: Apr 2004
Location: Cumbria, England
Distribution: openSuSE, Red Hat, HP-UX
Posts: 70

Rep: Reputation: 15
This is the simple way of doing it:
If each field is a single word seperated by white space then then use
sort -k2 <file>
If you have spaces within the fields you need to change the field seperator and use the -t option to indicate what it is.
Old 07-15-2005, 02:27 AM   #3
LQ Newbie
Registered: Apr 2005
Location: India
Distribution: Redhat 9
Posts: 17

Original Poster
Rep: Reputation: 0
thanks, I also found it thru man page


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell Scripting: Getting a pid and killing it via a shell script topcat Programming 15 10-28-2007 02:14 AM
shell interface vs shell scripting? I'm confused jcchenz Linux - Software 1 10-26-2005 03:32 PM
Shell Scripting again yaadhav Linux - Newbie 8 08-04-2005 10:21 AM
shell scripting pcdebb Linux - Newbie 17 11-20-2003 03:49 PM
shell scripting markus1982 Linux - General 2 05-20-2003 07:42 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:06 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration