Multi level sorting script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Multi level sorting script
# 1  
Old 06-25-2011
Error Multi level sorting script

I want to sort like below

Suppose few lines in a file is like this

systemid:ABC messagedestination:batchxpr replytoqname: myca
systemid:BCD messagedestination:realtime replytoqname: myca
systemid:ABC messagedestination:realtime replytoqname: eac
systemid: BCD messagedestination:mqonline replytoqname: myca

I want to first perform sorting according to value of systemid i.e. ABC,BCD,FGH

So it should be sorted first like this
systemid:ABC messagedestination:batchxpr replytoqname: myca
systemid:ABC messagedestination:realtime replytoqname: eac

systemid:BCD messagedestination:realtime replytoqname: myca
systemid: BCD messagedestination:realtime replytoqname: myca

so that same system ids are bundled together

Then after that i want to sort according to message destination.
so it shgould be like divided again
systemid:ABC messagedestination:batchxpr replytoqname: myca

systemid:ABC messagedestination:realtime replytoqname: eac

systemid:BCD messagedestination:realtime replytoqname: myca
systemid: BCD messagedestination:realtime replytoqname: myca

And finally according to reply to q name

So you get the picture, lines having same systemid,msgdestination and reply to q name shud be bundled together in the output Smilie

Can anyone help me in this???

Thanks in advance
# 2  
Old 06-25-2011
Hi, try:
Code:
sort -t: -k2,2 infile
sort -t: -k3,3 infile
sort -t: -k4,4 infile

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Multi line sorting in Linux

I have log files with following format - YYYY/MM/DD HH:mm:ss.msec|field2|filed3| log message Now the message itself can be multi line message containing new line character. for e.g. 2013/02/05 15:33:12.234|abc|xyz| This is first single line message. 2013/02/05 15:33:12.786|abc|xyz| This... (6 Replies)
Discussion started by: gini32
6 Replies

2. Homework & Coursework Questions

Help with Simple Multi-Level Makefile (Extremely New at Makefile)

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Basically, the prompt is make a makefile with various sub makefiles in their respective subdirectories. All code... (1 Reply)
Discussion started by: Tatl
1 Replies

3. UNIX for Dummies Questions & Answers

Assistance with combining, sorting and saving multi files into one new file

Good morning. I have a piece of code that is currently taking multiple files and using the CAT.exe command to combine into one file that is then sorted in reverse order based on the 3rd field of the file, then displayed on screen. I am trying to change this so that the files are being combined into... (4 Replies)
Discussion started by: jaacmmason
4 Replies

4. Homework & Coursework Questions

Four-Level multi-paging on x86 system with 64 bit addressing

1. The problem statement, all variables and given/known data: Hi all, I've got a huuuuuuge problem with understanding this new concept of multi-paging. I really tried to research but i could not find anything significant. I've been trying to understand this for 4 days and i cannot. The question... (0 Replies)
Discussion started by: snowboarder
0 Replies

5. Shell Programming and Scripting

Sorting multi-column values from a specific file

Hi, all. I need a shell script which gathers data from a remote XML file and then displays it according to my needs.. I need this for my job due to the fact that I need to keep track price changes of euro, usd, gold, etc. The XML file I am talking about is located at this page: cnnturk dot... (4 Replies)
Discussion started by: canimsin
4 Replies

6. Shell Programming and Scripting

sorting multi dimensional array

Hi there, Can someone let me know how to sort the 2 dimensional array below by column 1 then by column 2? 22 55 2222 2230 33 66 44 58 222 240 11 25 22 60 33 45 output: 11 25 22 55 22 60 33 45 33 66 44 58 (6 Replies)
Discussion started by: phoeberunner
6 Replies

7. Solaris

Difference between run level & init level

what are the major Difference Between run level & init level (2 Replies)
Discussion started by: rajaramrnb
2 Replies

8. Shell Programming and Scripting

Problem while using grep (multi-level) with the space-separated filepath.

Hi, I've been trying to use grep to find out all the files which have two particular patterns in it (both pattern1 AND pattern2). I have a script to do the same, in which I'm getting the output of the first grep (with -l option) which contains the list of file paths and I'm trying to search for... (3 Replies)
Discussion started by: NanJ
3 Replies

9. UNIX for Advanced & Expert Users

sorting data based on multi columns

Hi all I have data in following format: CSCH74,2007,1,09103,15 CSCH74,2007,10,09103,0 CSCH74,2007,11,09103,0 CSCH74,2007,12,09103,0 CSCH74,2007,2,09103,15 CSCH74,2007,3,09103,194 CSCH74,2007,4,09103,115 CSCH74,2007,5,09103,66 CSCH74,2007,6,09103,0 CSCH74,2007,7,09103,0... (2 Replies)
Discussion started by: sumeet
2 Replies
Login or Register to Ask a Question