Help with list of latest file names


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Help with list of latest file names
# 1  
Old 08-06-2010
Help with list of latest file names

Hi Gurus,

I need to list only those files which are most recent and the latest log file.

For example if I have the following file list:
Code:
JOB001.LOG_00uv02_00006 - Jul  7 12:16
JOB001.LOG_00vi0t_00001 - Aug  4 21:58
JOB001.LOG_00vi0t_00002 - Aug  5 09:15
JOB001.LOG_00vi0t_00003 - Aug  5 09:18
JOB002.LOG_00vi12_00001 - Aug  4 22:03
JOB002.LOG_00vi12_00002 - Aug  5 10:15
JOB003.LOG_00vm11_00001 - Aug 5 10:30

How to list only the below mentioned files:
Code:
JOB001.LOG_00vi0t_00003 - Aug  5 09:18
JOB002.LOG_00vi12_00002 - Aug  5 10:15
JOB003.LOG_00vm11_00001 - Aug 5 10:30

Please note that I don't have any permissions to write a shell script on this folder. Kindly help!

Thanks
Shash

Last edited by Yogesh Sawant; 08-27-2010 at 10:47 AM.. Reason: added code tags
# 2  
Old 08-06-2010
Code:
ls -lrt

shows the files in sorted order.

Last edited by Yogesh Sawant; 08-27-2010 at 10:47 AM.. Reason: added code tags
# 3  
Old 08-06-2010
Sorry, my query was not clear. I know I can use ls -lrt but the problem is I don't want all the logs of the same job to be listed. There are hundreds of them and I want to list only the latest log of a particular job. Hope this is clear.
# 4  
Old 08-06-2010
ls -ltr | grep "Aug 5" or you can use find with -mtime.
# 5  
Old 08-06-2010
A shell script does not have to be created in the target folder. You could presumably create a shell script in your home directory and refer to the folder with its full hierarchial name.
# 6  
Old 08-26-2010
Code:
ls -lt | head -n 5


Last edited by Yogesh Sawant; 08-27-2010 at 10:48 AM.. Reason: added code tags
# 7  
Old 08-26-2010
Code:
# ls -l JOB* | grep "Aug 5" |tail -n3
-rw-r--r-- 1 root root 0 Jun 25 05:13 JOB001.LOG_00vi0t_00003 - Aug 5 09:18
-rw-r--r-- 1 root root 0 Jun 25 05:13 JOB002.LOG_00vi12_00002 - Aug 5 10:15
-rw-r--r-- 1 root root 0 Jun 25 05:13 JOB003.LOG_00vm11_00001 - Aug 5 10:30

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Need help with UNIX command to get the latest file from list of files with timestamp

Hi All, I have list of files like below with name abcxyz.timestamp. I need a unix command to pick the latest file from the list of below files. Here in this case the lates file is abcxyz.20190304103200. I have used this unix command "ls abcxyz*|tail -1" but i heard that it is not the appropriate... (2 Replies)
Discussion started by: rakeshp
2 Replies

2. Shell Programming and Scripting

I have this list of files . Now I will have to pick the latest file based on some condition

3679 Jul 21 23:59 belk_rpo_error_**po9324892**_07212014.log 0 Jul 22 23:59 belk_rpo_error_**po9324892**_07222014.log 3679 Jul 23 23:59 belk_rpo_error_**po9324892**_07232014.log 22 Jul 22 06:30 belk_rpo_error_**po9324267**_07012014.log 0 Jul 20 05:50... (5 Replies)
Discussion started by: LoneRanger
5 Replies

3. 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

4. Shell Programming and Scripting

Shell script to get the latest file from the file list and move

Hi, Anybody help me to write a Shell Script Get the latest file from the file list based on created and then move to the target directory. Tried with the following script: got error. A=$(ls -1dt $(find "cveit/local_ftp/reflash-parts" -type f -daystart -mtime -$dateoffset) | head... (2 Replies)
Discussion started by: saravan_an
2 Replies

5. Shell Programming and Scripting

List the file names that differ

Hello, I have two directories - prev and current . They both have same multiple subdirectories and files. Now the current directory can have some updated files and some new files added that is not in prev. I want to find the list of file names that differ. I am doing this because i can not... (2 Replies)
Discussion started by: jakSun8
2 Replies

6. Shell Programming and Scripting

How to get the dates from a list of file names?

Hi All, I have a .txt file with the list of filenames as given below. /dev_data/dev3/ctl/20120622_Employee.txt /dev_data/dev3/ctl/20120623_Employee.txt /dev_data/dev3/ctl/20120624_Employee.txt I want to read this file & write the dates alone from the filenames into a .done file. ... (6 Replies)
Discussion started by: dsfreddie
6 Replies

7. Shell Programming and Scripting

get file names from the list

Hi Experts, Here is my scenario: Am maintaining a file which has list of logs with complete path and file names like bleow a/b/c/Daily/file1_20111012.log d/e/f/Monthly/file1_20111001.log g/h/Daily/file1_20110120.log i/Daily/file1_20110220.log How to copy the file names frm the list... (7 Replies)
Discussion started by: laxm
7 Replies

8. Shell Programming and Scripting

List of file names

I have the following list of file names stored in $fnames, so that if I do foreach f ($fnames) echo "$f" end I will get n02-z30-sr65-rgdt0p50-dc0p002-16x12drw-run1 n02-z30-sr65-rgdt0p50-dc0p002-16x12drw-run2 n02-z30-sr65-rgdt0p50-dc0p002-16x12drw-run3... (3 Replies)
Discussion started by: kristinu
3 Replies

9. UNIX for Dummies Questions & Answers

Get List of Unique File Names

I have a large directory of web pages. I am doing a search through the web pages using grep and would like to get a list of unique file names of search results. The following command works fine to give me a list of file names where term appears: grep -l term *.html However, since these are... (3 Replies)
Discussion started by: rjulich
3 Replies

10. Shell Programming and Scripting

ksh: How to get latest file from a list of files in a directory

Hi, I need to get the latest file from a list of files in a particular directory. Please could anyone help me out to get the file. Thank you, - Jay. (1 Reply)
Discussion started by: Jayathirtha
1 Replies
Login or Register to Ask a Question