LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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, 08:53 AM   #1
sryzdn
Member
 
Registered: Feb 2013
Posts: 248

Rep: Reputation: 1
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, 09:05 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,133

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


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


All times are GMT -5. The time now is 05:20 AM.

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