The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
sorting fields of a line Digby UNIX for Dummies Questions & Answers 6 03-12-2008 09:29 AM
ls positional parameter vasuarjula AIX 1 02-13-2008 10:49 PM
Sorting Files / Combing Fields / Printing ccfc1986 Shell Programming and Scripting 12 12-03-2007 02:38 PM
Sorting Compressed Fields ndoggy020 UNIX for Dummies Questions & Answers 1 06-05-2007 05:59 PM
Positional Parameters google Shell Programming and Scripting 2 09-26-2003 01:51 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-01-2008
ganapati's Avatar
ganapati ganapati is offline
Registered User
  
 

Join Date: Jul 2006
Location: Mysore
Posts: 125
Question Sorting 2 positional fields

Hi Friends,

I've a large datafile, I've to sort the entire records of this file based on the positions. For ex:

ccc112IVEAGH VETERINARY SERVICES
cca110SHOOTER PROPERTY SERVICES
bbb111JUNIOR GOLF ACADEMY LIMITED
aaa110AULD PROPERTIES T/A R&J AULD
ccb111LISBURN FUELS
aac112P & MRS C LE ROUX T/A CURVES
bbc112ENNISKILLEN LAWN TENNIS CLUB
aab111BALLYDOWN KIDS ACADEMY LTD
bba110ROYAL ULSTER AGRICULTURAL SO


The above records have to be sorted from the position 1-3 and 4-6(This is only example, position may differ). I know how to sort records for one field using "sort" command. But positionwise and for two fields I dont know.
The expected result should be:

aaa110AULD PROPERTIES T/A R&J AULD
aab111BALLYDOWN KIDS ACADEMY LTD
aac112P & MRS C LE ROUX T/A CURVES
bba110ROYAL ULSTER AGRICULTURAL SO
bbb111JUNIOR GOLF ACADEMY LIMITED
bbc112ENNISKILLEN LAWN TENNIS CLUB
cca110SHOOTER PROPERTY SERVICES
ccb111LISBURN FUELS
ccc112IVEAGH VETERINARY SERVICES


Please help me

Thanks in advance / Mysore Ganapati
  #2 (permalink)  
Old 02-01-2008
ennstate ennstate is offline
Registered User
  
 

Join Date: Mar 2007
Location: Chennai
Posts: 222
Try
Code:
 sort -k1,3 -k4,6 YourFile
Thanks
Nagarajan G
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 05:39 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0