Listing files

 
Thread Tools Search this Thread
Operating Systems Linux SuSE Listing files
# 1  
Old 07-29-2011
Question Listing files

Hi,

This may be silly for some of you guys, but please guide me,

I have the followin fies in my directory,

Code:
root@unix:/onlineredo/XTT77 : ls -l
total 4129992
-rw------- 1 XTT77 XTT77 10493952 Jul 28  2010 S0106839.LOG
-rw------- 1 XTT77 XTT77 10493952 Jul 28  2010 S0106840.LOG
-rw------- 1 XTT77 XTT77 67117056 Jul 28 10:06 S0162200.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 28 10:48 S0162201.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 28 11:28 S0162202.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 28 12:06 S0162203.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 28 12:52 S0162204.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 28 13:12 S0162205.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 28 14:06 S0162206.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 28 14:53 S0162207.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 28 15:54 S0162208.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 28 16:53 S0162209.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 28 17:57 S0162210.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 28 19:00 S0162211.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 28 19:01 S0162212.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 28 19:02 S0162213.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 28 19:03 S0162214.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 28 21:57 S0162215.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 28 23:17 S0162216.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 29 00:33 S0162217.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 29 01:12 S0162218.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 29 01:48 S0162219.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 29 02:29 S0162220.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 29 02:34 S0162221.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 29 02:40 S0162222.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 29 02:51 S0162223.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 29 04:12 S0162224.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 29 04:21 S0162225.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 29 04:22 S0162226.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 29 04:23 S0162227.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 29 04:23 S0162228.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 29 04:24 S0162229.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 29 04:25 S0162230.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 29 04:50 S0162231.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 29 05:17 S0162232.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 29 05:45 S0162233.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 29 06:34 S0162234.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 29 07:13 S0162235.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 29 07:45 S0162236.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 29 08:23 S0162237.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 29 09:00 S0162238.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 29 09:45 S0162239.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 29 10:24 S0162240.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 29 10:43 S0162241.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 29 10:44 S0162242.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 29 10:45 S0162243.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 29 10:47 S0162244.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 29 11:02 S0162245.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 33513472 Jul 29 11:31 S0162246.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 29 12:12 S0162247.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 29 12:47 S0162248.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 29 12:48 S0162249.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 29 12:49 S0162250.LOG.XTT77.XTT77.
-rw------- 1 XTT77 XTT77 67117056 Jul 29 12:51 S0162251.LOG.XTT77.XTT77.

I need to list only the files from S0162200 to S0162225.

How to do this...?

Regards,
Suren

Last edited by radoulov; 07-29-2011 at 05:23 PM.. Reason: Code tags!
# 2  
Old 07-29-2011
Try:
Code:
ls -l | awk '{x=$9;sub (".","",x);split(x,a,".")}a[1]>=162200&&a[1]<=162225'

This User Gave Thanks to bartus11 For This Post:
# 3  
Old 07-29-2011
With ksh and bash (with extended globbing enabled: shopt -s extglob) you could use something like this:


Code:
ls -1 S01622@([01][0-9]|[2][0-5]).LOG.XTT77.XTT77.

With zsh:

Code:
ls -1 S0162<200-225>.LOG.XTT77.XTT77.

If none of them is available:

Code:
printf '%s\n' S*LOG.XTT77.XTT77. |
  awk -F. 'substr($1, 3) >= 162200 && substr($1, 3) <= 1622225'

This User Gave Thanks to radoulov For This Post:
# 4  
Old 07-29-2011
Quote:
Originally Posted by bartus11
Try:
Code:
ls -l | awk '{x=$9;sub (".","",x);split(x,a,".")}a[1]>=162200&&a[1]<=162225'

Thanks bartus11, that worked fine... Smilie

If you don't mind, can you pleaz explain me what exactly did that awk do...?

---------- Post updated at 04:32 PM ---------- Previous update was at 04:17 PM ----------

Quote:
Originally Posted by radoulov
With ksh and bash (with extended globbing enabled: shopt -s extglob) you could use something like this:


Code:
ls -1 S01622@([01][0-9]|[2][0-5]).LOG.XTT77.XTT77.

With zsh:

Code:
ls -1 S0162<200-225>.LOG.XTT77.XTT77.

If none of them is available:

Code:
printf '%s\n' S*LOG.XTT77.XTT77. |
  awk -F. 'substr($1, 3) >= 162200 && substr($1, 3) <= 1622225'

Thanks radoulov, that worked. Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Listing the file name and no of records in each files for the files created on a specific day

Hi, I want to display the file names and the record count for the files in the 2nd column for the files created today. i have written the below command which is listing the file names. but while piping the above command to the wc -l command its not working for me. ls -l... (5 Replies)
Discussion started by: Showdown
5 Replies

2. Shell Programming and Scripting

listing files

Hi Guys, I need to list out the files which are not ending with particular extension in ksh but the extension can come within the file name. Please help me.. Thanks (2 Replies)
Discussion started by: jesu
2 Replies

3. Shell Programming and Scripting

Listing the files

Hi, I have to list the files in a particular folder which are having file names like below: 1000_aa.csv, 1000_ab.csv, 1000_az.csv,1000_ba.csv,1000_bb.csv,1000_ca.csv,1000_cb.csv. How can i get the list? Thanks, Selva (2 Replies)
Discussion started by: bharathappriyan
2 Replies

4. Shell Programming and Scripting

perl script for listing files and mailing the all files

Hi, I am new to perl: I need to write perl script to list all the files present in directory and mail should be come to my inbox with all the files present in that directory. advanced thanks for valuable inputs. Thanks Prakash GR (1 Reply)
Discussion started by: prakash.gr
1 Replies

5. UNIX for Dummies Questions & Answers

Listing files

how would i list all files, directories and exectable files in my directory? is there anyway to find out what date a file was created? Thanks!! (2 Replies)
Discussion started by: trob
2 Replies

6. UNIX for Dummies Questions & Answers

Listing files

Hi there! I would like to list all the files from a directory and its subdirectories. For example: DIRECTORY |- SUBDIR1 ||- sub1.txt ||- sub2.txt |- SUBDIR2 ||- sub3.txt |- root1.txt |- root2.txt I would like to create a fulllist.txt file which contains the list of these files (with... (2 Replies)
Discussion started by: bobix
2 Replies

7. UNIX for Advanced & Expert Users

listing files excluding files from control file

I have a directory named Project.I have a control file which contains valid list of files.I would like list the files from directory Project which contains files other than listed in the control file. Sample control file: TEST SEND SFFFILE CONTL The directory contains followign... (15 Replies)
Discussion started by: ukatru
15 Replies

8. Programming

Listing Files

Dear All, I want to list all the files of a Directory. I am not able to find out the code. So plz send me code in C in Unix Environmrnt so that I can Display all the file names of a Directory (3 Replies)
Discussion started by: krishna_sicsr
3 Replies

9. Linux

Listing of files

How can I list all files in a directory and its subdirectories that have been created or changed since the system was booted. I was trying to acomplish this with "ls" and "find" commands but could not get anything usefull. Maybe some one can provide me a hint. Thank you for your time. (1 Reply)
Discussion started by: Vitalka
1 Replies

10. UNIX for Dummies Questions & Answers

Recursive directory listing without listing files

Does any one know how to get a recursive directory listing in long format (showing owner, group, permission etc) without listing the files contained in the directories. The following command also shows the files but I only want to see the directories. ls -lrtR * (4 Replies)
Discussion started by: psingh
4 Replies
Login or Register to Ask a Question