How can I sort the file names in the directory


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How can I sort the file names in the directory
# 1  
Old 04-24-2009
How can I sort the file names in the directory

Hi ,

I have a list of files in the directory I want to sort based on the file name.
But in the middle of filename contains the number based on that I need to sort.Could you suggest me on the same?

Example filenames:

/user1$ls
RS.DEV.ISV.F1.RS.REFDATA.DATA
RS.DEV.ISV.F200.RS.REFDATA.DATA
RS.DEV.ISV.F2.RS.REFDATA.DATA
RS.DEV.ISV.F3.RS.REFDATA.DATA

in above files after the third .(dot) "Fxxxxx" part is incrementing.Based on that I need to sort.

ThanksinAdvance,
Praveen.
# 2  
Old 04-24-2009
Code:
printf '%s\n' *.DATA|sort -t. -k4.2n

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Sort a text file based on names in square brackets

Hi all, I have a text file similar to this: Text More text Etc Stuff That Is Needed Etc Etc This contains over 70 entries and each entry has several lines of text below the name in square brackets. (5 Replies)
Discussion started by: Scally
5 Replies

2. UNIX for Beginners Questions & Answers

Renaming the file names in a directory

Hi, I have about 60 files in a directory and need to rename those files. For example the file names are i_can_phone_yymmdd.txt (where yymmdd is the date. i.e 170420 etc) i_usa_phone_1_yymmdd.txt i_eng_phone_4_yymmdd.txt The new file names should be phone.txt phone_1.txt phone_4.txt I am... (4 Replies)
Discussion started by: naveed
4 Replies

3. Shell Programming and Scripting

Sort html based on .jar, .war file names and still keep text within three groups.

Output from zipdiff GNU EAR comparison tool produces output in html divided into three sections "Added, Removed, Changed". I want the output to be sorted by jar or war file. <html> <body> <table> <tr> <td class="diffs" colspan="2">Added </td> </tr> <tr><td> <ul>... (5 Replies)
Discussion started by: kchinnam
5 Replies

4. UNIX for Dummies Questions & Answers

[Solved] Reverse the order of a list of file names (but not sort them alphabetically or numerically)

Hello all, I have a list of file names in a text document where each file name consists of 4 letters and 3 numbers (for example MACR119). There are 48 file names in the document (they are not in alphabetical or numerical order). I would like to reorder the list of names so that the 48th name is... (3 Replies)
Discussion started by: MDeBiasse
3 Replies

5. UNIX for Dummies Questions & Answers

List Directory names which have the file

Hi All, Can any one help me to list out the directory names which contain the specified file. See for example File name : file.201307014.LKT Have the directory structure as below. /app/work/data/INDIA/file.201307014.LKT /app/work/data/AMERICA/file.201307014.KTP... (5 Replies)
Discussion started by: Balasankar
5 Replies

6. Shell Programming and Scripting

Grepping file names, comparing them to a directory of files, and moving them into a new directory

got it figured out :) (1 Reply)
Discussion started by: sHockz
1 Replies

7. Shell Programming and Scripting

How to read file names in the directory?

I am having n files in a directory i want to read all the file names from the script file .It is better if any one provide a sample script. Elaborating the scenario: i am having n number of sql files in a directory i am running all the sql files from a single script. sqlplus... (4 Replies)
Discussion started by: dineshmurs
4 Replies

8. Shell Programming and Scripting

Searching for file names in a directory while ignoring certain file names

Sun Solaris Unix Question Haven't been able to find any solution for this situation. Let's just say the file names listed below exist in a directory. I want the find command to find all files in this directory but at the same time I want to eliminate certain file names or files with certain... (2 Replies)
Discussion started by: 2reperry
2 Replies

9. UNIX for Dummies Questions & Answers

Sort directory with complex numeric file names

I have a directory with a large number (1000s) of files and I need to produce a file listing all the files in the directory ordered "properly" (properly will be explained shortly). The files have the following naming pattern: bul_13_5_228_b.txt bul_1_3_57.txt bul_13_6_229.txt... (2 Replies)
Discussion started by: fdsayre
2 Replies

10. Shell Programming and Scripting

How to sort directory names and use only last?

I need help writing a bash script for the windows cygwin environment. I'm not sure if bash is the optimal tool. Perhaps perl would be better? Either would work. I have directories whose names include the date they were created. The directory names are in the format of... (0 Replies)
Discussion started by: siegfried
0 Replies
Login or Register to Ask a Question