multiple sort


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers multiple sort
# 8  
Old 10-10-2005
Quote:
Originally Posted by Just Ice
sort -n +0 +3 +4 infile
thanks,

i tried with the following sample
3 88.31 264011 0000540195 0032640028 2005-09-17 14:51:20
3 88.31 260811 0000540195 0032640028 2005-09-17 14:52:39
3 33.23 064898 1007441330 0059704869 2005-09-17 15:50:08
3 33.23 001398 1001241330 0597004869 2005-09-17 15:49:11


Code:
sort -n +0 +5 +6 file

it only sorts successfully based on the first column (though it is already sorted)
and on the 6th and 7th column it fails

and my piece works fine.
# 9  
Old 10-14-2005
a small modification ...

Quote:
Originally Posted by teletype_error
awk '{print $1}' file | sort | uniq | while read line
do
grep ${line} file | awk '{ if ( $1=='${line}' ) print $4, $5 }' | \
sed -e 's/[-, ]/:/g' | sort -t":" | sed -e 's/:/-/;s/:/-/;s/:/ /' | while read sub
do
grep ${line} file | grep "${sub}" | uniq | awk '{ if ( $1=='${line}' ) print }'
done
done
# 10  
Old 06-29-2006
Sort question on Sun

Hello,

I tried to sort on column2 followed by column1 and notice how the "updated" value in column1 is not sorted correctly!

Can you tell me if i have the sort statement setup correctly please, thanks much!


sort -t "|" -k2 -k1 sortin > sortout


caller|wf_item|WF_ITEM.doc|Create_Item|Item_Exist|516
caller|wf_item|WF_ITEM.doc|Create_Item|Item_Exist|517
caller|WF_ITEM|WF_ITEM.doc||in|7
caller|wf_item|WF_ITEM.doc|InitCache|SetEndDate|162
caller|wf_item|WF_ITEM.doc|InitCache|SetEndDate|163
caller|wf_item|WF_ITEM.doc|InitCache|SetEndDate|172
caller|wf_item|WF_ITEM.doc|InitCache|SetEndDate|194
caller|wf_item|WF_ITEM.doc|InitCache|SetEndDate|194
ubdated|wf_item|WF_ITEM.doc|InitCache|SetEndDate|194
ubdated|wf_item|WF_ITEM.doc|InitCache|SetEndDate|194
caller|wf_item|WF_ITEM.doc|InitCache|SetEndDate|195
caller|wf_item|WF_ITEM.doc|InitCache|SetEndDate|195
ubdated|wf_item|WF_ITEM.doc|InitCache|SetEndDate|195
ubdated|wf_item|WF_ITEM.doc|InitCache|SetEndDate|195
caller|wf_item|WF_ITEM.doc|InitCache|SetEndDate|200
caller|wf_item|WF_ITEM.doc|InitCache|SetEndDate|201
caller|WF_ITEM|WF_ITEM.doc|InitCache|SetEndDate|205
caller|Wf_Item|WF_ITEM.doc|Root_Process|Item_Exist|444
caller|wf_item|WF_ITEM.doc|Root_Process|Item_Exist|445
caller|wf_item|WF_ITEM.doc|Root_Process|Item_Exist|446
caller|wf_item|WF_ITEM.doc|SetItemUserKey|GetItemUserKey|383
caller|wf_item|WF_ITEM.doc|SetItemUserKey|GetItemUserKey|384
caller|wf_item|WF_ITEM.doc|SetItemUserKey|GetItemUserKey|385
caller|Wf_Item|WF_ITEM.doc|SetItemU
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Ls -ltr Sort multiple columns

Hi All, I have one requirement, where I need to have output of ls -l command sorted on 1) first on filename 2) last modified time ( descending ) - latest change first. I am not able to figure out how to do it.. Also I dont have a way to change Date display for ls -ltr command.. I am... (1 Reply)
Discussion started by: freakabhi
1 Replies

2. UNIX for Dummies Questions & Answers

Sort with multiple keys

Please suggest a sort command to achieve the below task. Thanks. I want to sort a file considering multiple keys. Sort Keys: Field 2, Field4 and Field6 Input file vqrs,16,zzz,1235,eq,T abcd,11,zzz,1234,pq,F abcd,10,zzz,1235,pq,F lqrs,15,zzz,1235,eq,T pqrs,12,zzz,1234,eq,F... (3 Replies)
Discussion started by: pretty1234
3 Replies

3. Shell Programming and Scripting

sort on multiple columns

hi all, i have a file , having few columns. i wanted to sort it based on 2nd column and then based on 1st column. But i have some problem in first column. first column have characters and numbers, but problem is number of characters are not same in all rows. Few rows have 13 characters and then... (3 Replies)
Discussion started by: deepakiniimt
3 Replies

4. Shell Programming and Scripting

sort on multiple columns

Howdy! Need to sort a large .txt file containing the following, using sort. First based on the 1st column, and then on the 2nd column: Group01.01 1000500 31 0.913 -1.522974494 Group01.01 1001500 16 0.684 -0.967496041 Group01.01 36500 19 0.476 na Group01.02 365500 15 0.400 na... (1 Reply)
Discussion started by: sramirez
1 Replies

5. Shell Programming and Scripting

sort by based on multiple columns

Hi, Is there any way to sort a file in cshell by sort command, sorting it by multiple fields, like to sort it first by the second column and then by the first column. Thanks forhead (1 Reply)
Discussion started by: Takeeshe
1 Replies

6. Shell Programming and Scripting

sort by multiple columns and reformat...

hello.. I have big file and so far I was able to shink it and make smaller with certains values that I need.. vendor1|2000|1 vendor2|1000|1 vendor2|5000|1 vendor2|500|2 vendor3|1000|2 vendor3|500|3 vendor4|500|3 Vendor5|500|1 vendor6|500|3 Vendor7|1000|1 Vendor8|1000|774... (3 Replies)
Discussion started by: abdulaziz
3 Replies

7. Shell Programming and Scripting

sort on multiple fields

Hello All I have data in a flat file with numeric and aplha numeric datatypes. Now i have to sort on multiple fileds. Can any body please give me the sort code? i am particularly confused about the sort code like sort -n +0 -1 +1 -2 .... (1 Reply)
Discussion started by: vasuarjula
1 Replies

8. Shell Programming and Scripting

sort on multiple fields

hello all I have a file names xxx with data like 1,2,3,12 1,3,6,12 1,3,5,12 2,4,6,12 6,5,6,12 4,2,7,12 4,1,3,12 I wish to sort this file xxx on first three fields in ascending order. OUPUT should be like 1,2,3,12 1,3,5,12 1,3,6,12 2,4,6,12 (4 Replies)
Discussion started by: vasuarjula
4 Replies

9. UNIX for Dummies Questions & Answers

Unix sort on multiple fields

Hello. I've read a few threads on how to sort on multiple fields, but I still can't get my file to sort correctly. I have a comma delimited .csv file will over a hundred fields. I want to sort it by field 2, field 62 and then field 61 (integer fields). input looks like this well swap field... (2 Replies)
Discussion started by: happy_cow
2 Replies

10. UNIX for Advanced & Expert Users

sort on multiple keys

Hello, Say I have a file with plain text as shown below. Some columns may have multiple words (like "DESC 1", "DESC 1 2", "DESC 1 2 3"). Let's say the file below has 4 columns: 1st(AA), 2nd(BB), 3rd(DESC 1, ...), 4th(CC 1, ...). 1234567890123456789012345678901234567890 AA BB DESC 1... (1 Reply)
Discussion started by: teqmem
1 Replies
Login or Register to Ask a Question