Extracting files having maximum timestamp


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Extracting files having maximum timestamp
# 8  
Old 07-09-2013
Hello smile689,

could you please try this, may be it will be helpful for you.

Code:
 
$ cat timings_file_query.ksh
 

echo "Please enter the number of files present types for files like file1, file2....till which file"
echo "eg--> lets say we have file1 to file30 so please enter 30 in the case"
 
 
read number_of_files

a=1

while [ ${a} -le ${number_of_files} ]
do

name=`echo "YDT:FILE"$a`
value_for_files_present_in_path=`ls -ltr | grep -v "grep" | grep $name | awk '{print$9}' | tail -1`
echo $value_for_files_present_in_path

let "a = a + 1"
done



Output is as follows:


Code:
 
$ ksh timings_file_query.ksh

Please enter the number of files present types for files like file1, file2....till which file
eg--> lets say we have file1 to file30 so please enter 30 in the case
2
YDT:FILE1:20130615
YDT:FILE2:20130622
$

Kindly let me know if you have any queries.


Thanks,
R. Singh
This User Gave Thanks to RavinderSingh13 For This Post:
# 9  
Old 07-12-2013
Thank You So Much YODA, Subbesh
It worked in my script.

Last edited by smile689; 07-12-2013 at 07:00 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extracting values after the maximum value in a txt file

Hello, I'm new to scripting and I need to write a bash script. Here is example of file on which I'm working: 0.3092381 0.3262799 0.3425480 0.3578379 0.3719490 0.3846908 0.3958855 0.4053738 0.4130160 0.4186991 0.4223357 0.4238688 ... (14 Replies)
Discussion started by: jeo_fb
14 Replies

2. Debian

Problem with maximum files and directories

Hi, I'm using Kali linux, I think it's a debian linux ? I'm trying to create a folder in which there'll be 256 folders, and in each of this folders there will also be 256 folders. Then in each terminate folders I want to create 4096 files. It will look like /dir/aa/aa/aaa.txt,... (3 Replies)
Discussion started by: ganon551
3 Replies

3. Shell Programming and Scripting

Finding the maximum timestamp in a folder

I've the files in a directory in the following format having date +%Y%m%d%H YR_MNTH_2013061205 YR_MNTH_2013060107 and i need the latest file i.e; YR_MNTH_2013061205 to be moved to another folder #!/bin/ksh # Ksh 88 Version for test_time in YR* do --- done How can i achieve that !... (2 Replies)
Discussion started by: smile689
2 Replies

4. Shell Programming and Scripting

Identifying files with a timestamp greater than a given timestamp

I need to be able to identify files with file timestamps greater than a given timestamp. I am using the following solution, although it appears to compare files at the "seconds" granularity and I need it at the milliseconds. When I tested my solution, it missed files that had timestamps... (3 Replies)
Discussion started by: nkm0brm
3 Replies

5. Shell Programming and Scripting

sort the files based on timestamp and execute sorted files in order

Hi I have a requirement like below I need to sort the files based on the timestamp in the file name and run them in sorted order and then archive all the files which are one day old to temp directory My files looks like this PGABOLTXML1D_201108121235.xml... (1 Reply)
Discussion started by: saidutta123
1 Replies

6. Shell Programming and Scripting

Sub directories containing maximum files

Hi All, I have this command coded in C Shell to get the top ten sub directories in the order of number of files they contain. find $parent_dir -type d -exec filecount {} \; | sort -nr | head -10 But it does not seem to show any output. Can someone please help me out in correcting this... (5 Replies)
Discussion started by: adurga
5 Replies

7. UNIX for Dummies Questions & Answers

ls - maximum number of files

what is the maximum number ls can list down (6 Replies)
Discussion started by: karnan
6 Replies

8. HP-UX

to get the timestamp of files from the files and folders in Unix

Hi, I had a directory and many subdirectories and files with in it. Now i want to get the timestamp of files from the files and folders recursively. :( Please help me to generate a script fort he above mentioned requirement! Appreciate for ur qick response Thanks in advance! ... (2 Replies)
Discussion started by: kishan
2 Replies

9. UNIX for Dummies Questions & Answers

Unix shell script for finding top ten files of maximum size

I need to write a Unix shell script which will list top 10 files in a directory tree on basis of size. i.e. first file should be the biggest in the whole directory and all its sub directories. Please suggest any ideas (10 Replies)
Discussion started by: abhilashnair
10 Replies

10. UNIX for Dummies Questions & Answers

Maximum files in a Directory

Does Solaris impose limits on : - the maximum number of files a directory can have, - total file size in a directory If there is such limits, how can I can check for each? Thanks...:confused: (1 Reply)
Discussion started by: deaniyoer
1 Replies
Login or Register to Ask a Question