LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


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

Rep: Reputation: 0
shell scripting


Hai,

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, 03:24 AM   #2
sorvad
Member
 
Registered: Apr 2004
Location: Cumbria, England
Distribution: openSuSE, Red Hat, HP-UX
Posts: 66

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, 03:27 AM   #3
carthyc
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
 
  


Reply


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 03:14 AM
shell interface vs shell scripting? I'm confused jcchenz Linux - Software 1 10-26-2005 04:32 PM
Shell Scripting again yaadhav Linux - Newbie 8 08-04-2005 11:21 AM
shell scripting pcdebb Linux - Newbie 17 11-20-2003 04:49 PM
shell scripting markus1982 Linux - General 2 05-20-2003 08:42 AM


All times are GMT -5. The time now is 01:14 PM.

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