Unable to sort file name in Unix


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Unable to sort file name in Unix
# 1  
Old 10-24-2011
Unable to sort file name in Unix

Hi,

I'm unable to sort the files with the required names on Unix. Details have been enclosed:-

Below are the fle name inside a folder, now i need to sort them in a way that they are group with the seconds occurance in the file name (E.g 01954,07947,06794)

01.01954.MXRS1.rcv
01.06794.MXRS2.rcv
01.07947.MXRS3.rcv
02.01954.MXRS4.rcv
02.06794.MXRS5.rcv
02.07947.MXRS6.rcv

Required result should be :-

01.01954.MXRS1.rcv
02.01954.MXRS4.rcv
01.06794.MXRS2.rcv
02.06794.MXRS5.rcv
01.07947.MXRS3.rcv
02.07947.MXRS6.rcv

Should sort by the above bold chanracters.

How to achieve this ?
# 2  
Old 10-24-2011
Code:
 sort -t. -k 2,2n

# 3  
Old 10-24-2011
thanks CarloM
# 4  
Old 10-24-2011
Code:
$ sort -t. +1n infile

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to Modify a file content in UNIX and sort for only required fields ?

I have the below contents in a file after making the below curl call curl ... | grep -E "state|Rno" | paste -sd',\n' | grep "Disconnected" > test "state" : "Disconnected",, "Rno" : "5554f1d2" "state" : "Disconnected",, "Rno" : "10587563" "state" : "Disconnected",, "Rno" :... (2 Replies)
Discussion started by: Vaibhav H
2 Replies

2. Shell Programming and Scripting

Sort help: How to sort collected 'file list' by date stamp :

Hi Experts, I have a filelist collected from another server , now want to sort the output using date/time stamp filed. - Filed 6, 7,8 are showing the date/time/stamp. Here is the input: #---------------------------------------------------------------------- -rw------- 1 root ... (3 Replies)
Discussion started by: rveri
3 Replies

3. UNIX for Dummies Questions & Answers

sort a unix file by 3rd column

Hi, Can anybody tell me how to sort a unix file by 3rd column and not by ltr? Please help Thanks in advance (2 Replies)
Discussion started by: vinnyvirk
2 Replies

4. Shell Programming and Scripting

Unix Scripting : Sort a Portion of a File and not the complete file

Need to sort a portion of a file in a Alphabetical Order. Example : The user adam is not sorted and the user should get sorted. I don't want the complete file to get sorted. Currently All_users.txt contains the following lines. ############## # ARS USERS ############## mike, Mike... (6 Replies)
Discussion started by: evrurs
6 Replies

5. UNIX for Advanced & Expert Users

Script to sort the files and append the extension .sort to the sorted version of the file

Hello all - I am to this forum and fairly new in learning unix and finding some difficulty in preparing a small shell script. I am trying to make script to sort all the files given by user as input (either the exact full name of the file or say the files matching the criteria like all files... (3 Replies)
Discussion started by: pankaj80
3 Replies

6. Shell Programming and Scripting

Unable to get the correct sort order in perl.

Hi, I have created the hash. %hash; @arr1 = qw(Dealnum AdminStatus adminReason effFrom effTo); @arr2 = qw(121212121 YES 1992-06-19T05:14:27 ); @hash{@arr1}=@arr2; foreach(sort keys %hash){ print "$_ ---- $hash{$_}\n"; } The output i got like this: C:\strawberry\perl\bin>perl... (1 Reply)
Discussion started by: vanitham
1 Replies

7. Shell Programming and Scripting

UNix one-liner to sort a file

Hi everyone, I have a txt file as: >001.b1 GCTAGTGCTAGCTAGCTAGCATCGATCGAT >002.b1 CAGTCAGTCGTAGTGCTAGCTGATGCTCGT >003.b1 CGATCGTAGTCGTATCGATGCTGACGTAGG >002.g1 ATGCTGATCGACTAGCTAGTCGT >015.b1 CGATCTAGTAGTGCTAGTCGTTT >001.g1 ATGCTGATCGACTAGCTAGTCGT >003.g1 CGATGCTAGTCGATGCTGACGGG (3 Replies)
Discussion started by: ad23
3 Replies

8. Shell Programming and Scripting

Unable to use sort command in Shell Script

Hello All, I am creating a shell script that reads a file(test.txt) with the following data, 0.0.0.0 10.10.10.0 10.10.10.1 10.10.10.10 10.10.10.2 10.10.10.3 10.10.10.4 10.10.10.5 10.10.10.6 10.10.10.7 10.10.10.8 10.10.10.9 If I use the sort, the highest value I am getting is... (1 Reply)
Discussion started by: racbern
1 Replies

9. UNIX for Dummies Questions & Answers

unix SORT

Hey guys. I am trying to sort a file by account number through UNIX. I have a few things but it seems to sort by account number AND sort everything after the account number. Help please. Thanks (5 Replies)
Discussion started by: ndoggy020
5 Replies

10. Shell Programming and Scripting

File size limitation of unix sort command.

hi , iam trying to sort millions of records which is delimited and i cant able to use sort command more than 60 million..if i try to do so i got an message stating that "File size limit exceeded",Is there any file size limit for using sort command.. How can i solve this problem. thanks ... (7 Replies)
Discussion started by: cskumar
7 Replies
Login or Register to Ask a Question