List files according to the numerical value


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers List files according to the numerical value
# 1  
Old 09-26-2011
List files according to the numerical value

Hi,

I have a large number of files which are named as follows.

VF_50, VF_100, VF_150, VF_250, VF_300, VF_350, VF_400, VF_450, VF_500.

When I do an 'ls' it arranges the files in the following way

VF_100, VF_150, VF_250, VF_300, VF_350, VF_400, VF_450, VF_50, VF_500.

Is there a way to arrange the files according to its numerical value, i.e. VF_50 has a lower numerical value than VF_100.

Thanks.
# 2  
Old 09-26-2011
Code:
 
ls | sort -t_ -n -k2

This User Gave Thanks to itkamaraj For This Post:
# 3  
Old 09-26-2011
Code:
$ ls VF* | sort -t_ +1n

This User Gave Thanks to jayan_jay For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Match and store numerical prefix to update files

In the bash below the unique headers of each vcf.gz are stored in a text file with the same name. That is if 16-0000-file.vcf.gz was used the header text file would be 16-0000-file_header.txt. There can be multiple vcf.gz in a directory, usually 3, that I need to fix the header in each file before... (6 Replies)
Discussion started by: cmccabe
6 Replies

2. Shell Programming and Scripting

Converting a list to a row to create clusters based on numerical identity

Hello. I have a long list of data which has the following structure The number shows the unique identity of the word. And all homophones are clustered with the same number ID. An example will make this clear The awk script I have allows conversion of a list to row but on condition that each... (4 Replies)
Discussion started by: gimley
4 Replies

3. Shell Programming and Scripting

how to extract data from numbered files using linux in the numerical order-

Hi experts, I have a list of files containing forces as the only number as follows. Force1.txt Force2.txt Force3.txt Force4.txt Force5.txt . . . . . . . . . Force100.txt I want to put all the data(only a number ) in these forces files in the file with the same order like 1,2,3 ..100 .... (2 Replies)
Discussion started by: hamnsan
2 Replies

4. Shell Programming and Scripting

Deleting particular files with a numerical suffix

Hello I have a directory with a list of files which have a particular numerical suffix. E.g filename_0 filename_1 filename_18500 filename_10000 I want to delete all files from this directory which have a filename which have a numerical suffix greater than 10540. So any files... (5 Replies)
Discussion started by: kamal_p_99
5 Replies

5. UNIX for Dummies Questions & Answers

finding and moving files based on the last three numerical characters in the filename

Hi, I have a series of files (upwards of 500) the filename format is as follows CC10-1234P1999.WGS84.p190, all in one directory. Now the last three numeric characters, in this case 999, can be anything from 001 to 999. I need to move some of them to a seperate directory, the ones I need to... (5 Replies)
Discussion started by: roche.j.mike
5 Replies

6. UNIX for Dummies Questions & Answers

moving/copying files in a numerical order

Hi I am newbie to unix scripting, but i have enough knowledge to understand. I have a specific questions like, I use to collect like 3500 files per experiment, each one named like data_001.img.. data_002.img data_003.img .... data_3500.img I would like to move every 12 files in the 3500... (3 Replies)
Discussion started by: wpat
3 Replies

7. UNIX for Dummies Questions & Answers

Moving files out of multiple directories and renaming them in numerical order

Hi, I have 500 directories each with multiple data files inside them. The names are sort of random. For example, one directory has files named e_1.dat, e_5.dat, e_8.dat, etc. I need to move the files to a single directory and rename them all in numerical order, from 1.dat to 1000(or some... (1 Reply)
Discussion started by: renthead720
1 Replies

8. Shell Programming and Scripting

compare files by numerical value

Hi everyone, I would love to have a script that does the following: I have one file that looks like that: ATOM 1 BB SER 1 1 -31.958 -25.125 -11.061 1.00 0.00 ATOM 3 BB GLY 1 2 -32.079 -26.085 -14.466 1.00 0.00 ATOM 4 BB VAL 1 3 ... (1 Reply)
Discussion started by: s-layer
1 Replies

9. Programming

Adding files of numerical data

Hi I was hoping that maybe someone could help me with a small piece of C code. I have a number of files, which are all of similar layout ie. three lines of text and 5-6 columns of numerical data. I need to add each of the elements of the second column in one file to their counterparts in the second... (17 Replies)
Discussion started by: Boucho
17 Replies

10. Shell Programming and Scripting

Listing files in numerical order

Hi, I'm trying to write a ksh script to copy a specified number of files from one directory to another. The files are named in the convention <switchname>_log.<num> and the numbers are sequential single digit onwards. I figured I could find some parameter for ls which would list the files in... (3 Replies)
Discussion started by: Steve_H
3 Replies
Login or Register to Ask a Question