LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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 03-13-2014, 07:53 AM   #1
sryzdn
Member
 
Registered: Feb 2013
Posts: 274

Rep: Reputation: 9
a question on sort command


Hi,

When we have several columns in a file separated by spaces, like the following:

Code:
Prowler		Desmond Lameborough TFC 13 Men
Fleetman	Fred Rundale Sportsters 217 Men
Smith		Herbert Pantington AC 123 Men
O'Finnan 	Jack Fairing Track Society 45 Men
Runnington 	Kathleen Lameborough TFC 119 Ladies
What is the difference between these two commands when we want to sort by the second column:

Quote:
1. sort -k 2 file
2. sort -k 2,2 file
 
Old 03-13-2014, 08:05 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,804

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
actually column 2 is unique, therefore there will be no difference, but try it with non-unique values and you will see
 
  


Reply



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
Sort command sceravo1 Linux - General 2 04-15-2013 09:37 AM
sort command fallloveuni Programming 3 01-24-2010 08:31 PM
Small question with the sort command Bleek Linux - Newbie 22 12-06-2009 04:49 AM
Sort command arya6000 Linux - Newbie 2 11-27-2007 07:50 PM
Using the Sort command in vi timnphx Programming 2 04-06-2001 11:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:47 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
Open Source Consulting | Domain Registration