LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 11-21-2001, 02:50 PM   #1
Scamps
LQ Newbie
 
Registered: Nov 2001
Posts: 8

Rep: Reputation: 0
Another daft newbie question


Hi,
I have a timetable list that I have sorted every way I can while playing with the sort utility. However, thrown into my list are a July 98 & a Dec 98. the rest of the dates vary across the months from Jan - Dec 99. My question is this:
Is there a way I can sort the list to display the 2 98 dates first then followed by the 99 dates, all in monthly order? the year & month are seperates fields. I seem to only be able to sort either the monthly field or the yearly field. is there a way I can sort the first 2 lines & then resort the remainder of the file ignoring the first 2 lines? Apologies for the daft question but if we don't ask then we don't learn!
Thanks
Scamps
 
Old 11-24-2001, 10:03 AM   #2
joe1011010
Member
 
Registered: Aug 2001
Location: UK
Posts: 48

Rep: Reputation: 15
Check the man page for sort... type 'man sort' at the prompt.

You need something like

sort -k5,6 -k1,3 ...

This sorts based on the year column first, then the month. I assume the month is only 3 characters in every line.

Joe
 
Old 11-24-2001, 01:39 PM   #3
Scamps
LQ Newbie
 
Registered: Nov 2001
Posts: 8

Original Poster
Rep: Reputation: 0
I read the manual before posting. I already tried -k but it's still not sorting the way I want it to. There's always either 1 or 2 of the lines that are not sorted in the correct order. I have 6 columns (fields) in the timetable (index, month, date, year, departure, destination). If I type: sort +3 -4 -n +1 -2 -bM then I get 2 lines incorrectly placed in the sort & the monthly sort starts at March instead of January. It doesn't make any sense to me why it's sorting in this way. If I type: sort -k 4,5 -n -k 2,3 -bM I get the same result.
 
  


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
daft desktop / gnome question gsd750 Linux - Newbie 2 09-10-2004 10:55 AM
Please answer some basic questions froma daft newbie jmpm Linux - Newbie 7 01-06-2004 06:49 AM
yet another daft floppy problem Bungholio Linux - General 5 07-07-2003 01:34 PM
Apache newbie question.. (very newbie question) tarballed Linux - Newbie 1 02-07-2003 08:41 PM
RE: Suse 8.0 hardware question {newbie question, pls help} Radiouk Linux - Distributions 2 06-04-2002 12:53 PM


All times are GMT -5. The time now is 04:00 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration