Find files greater than a particular date in filename.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find files greater than a particular date in filename.
# 1  
Old 07-30-2012
Find files greater than a particular date in filename.

I need a unix command which will find all the files greater that a particular date in the file name.

say for example I have files like(filenaming cov : filename.YYDDMMSSSS.txt)

Code:
abc.201206015423.txt
abc.201207013456.txt
abc.201202011234.txt
abc.201201024321.txt
efg.201202011234.txt
efg.201201024321.txt

Now say I want to find abc.* files whose date is >= 20120201.
Can you please provide a unix command to get the file names ?

Thanks in advance

Last edited by Scott; 07-30-2012 at 11:05 AM.. Reason: Code tags
# 2  
Old 07-30-2012
it is really day before month? are the files in the same directory or do you need to search sub directories?
# 3  
Old 07-30-2012
Thanks for responding.
All the files are in same directory.
The date can be any date. I will have a variable for that.
I just gave a date in the example.

Thanks
# 4  
Old 07-30-2012
Think this should do you:

Code:
$ awk -F'.' 'int($2)>'201206000000' {print $0}' test.sh
abc.201206015423.txt
abc.201207013456.txt

This User Gave Thanks to Vryali For This Post:
# 5  
Old 07-30-2012
I didnt clearly get it. Why do we need test.sh here ?
# 6  
Old 07-30-2012
You say that the file naming convention is
Quote:
filename.YYDDMMSSSS.txt
but the example looks a lot more like the convention is
Quote:
filename.YYYYDDMMSSSS.txt
or
filename.YYYYMMDDSSSS.txt
I can't tell which it is from the data you supplied.
It is good that the convention uses YYYY instead of YY so it can handle century roll over issues like the Y2K problems some of us lived through.

If the convention is YYYYMMDDSSSS the script Vryali gave works fine (assuming that test.sh is a file containing a list of the files you're examining). If the convention is YYYYDDMMSSSS, you have more work to do to rearrange the month and day into an order that will sort correctly.
This User Gave Thanks to Don Cragun For This Post:
# 7  
Old 07-30-2012
Hi
I tried this
Code:
ls abc.* | awk -F'.' 'int($2)>'201206000000' {print $0}'

and it doesnt show up anything

Thanks

---------- Post updated at 01:11 PM ---------- Previous update was at 01:09 PM ----------

sorry the naming convention is filename.YYYYMMDDSSSS.txt
still no luck.

Last edited by Franklin52; 07-31-2012 at 05:34 AM.. Reason: Please use code tags for data and code samples
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

To find files having filename containing specific date format

Hi, I have a requirement to create a shell script(tcsh) that finds all the files in a directory having the file name containing date format "YYYYMMDDHHMM" and extract the date time part ""YYYYMMDDHHMM" for further processing. Could you please have any idea on this. trades_201604040000.out... (6 Replies)
Discussion started by: gopal.biswal
6 Replies

2. Shell Programming and Scripting

Find file by filename or with newest modified date

Hi, I have a directory that has numerous files in it, and there is two which are named "filerec_ddmmyyHH24MMSS" by the time they are created so "filerec_010615012250" was created at 01:22:50 on 1st June 2015. I need to find the most recently created of those 2 files and get the contents of... (4 Replies)
Discussion started by: finn
4 Replies

3. Shell Programming and Scripting

Please help list/find files greater 1G move to different directory

I have have 6 empty directory below. I would like write bash scipt if any files less "1000000000" bytes then move to "/export/home/mytmp/final" folder first and any files greater than "1000000000" bytes then move to final1, final2, final3, final4, final4, final5 and that depend see how many files,... (6 Replies)
Discussion started by: dotran
6 Replies

4. Shell Programming and Scripting

Find the latest file based on the date in the filename

Hi, We've a list of files that gets created on a weekly basis and it has got a date and time embedded to it. Below are the examples. I want to find out how to get the latest files get the date and time stamp out of it. Files are PQR123.PLL.M989898.201308012254.gpg... (1 Reply)
Discussion started by: rudoraj
1 Replies

5. Shell Programming and Scripting

Find file that matches today's date in filename and move to /tmp in bash

I'm having problems with my bash script. I would like to find a file matching today's date in the filename, i.e. my_file_20120902.txt and then move it to a different directory, i.e. /tmp. Thanks. (1 Reply)
Discussion started by: jamesi
1 Replies

6. UNIX for Dummies Questions & Answers

List of Files which are Greater then a specific date

A newbie question... I need to get a list of the Files and folders which are greater then a specific date. I want write the output to a Text file. What I know ls -lrt gives me list of all the files ordered by date. Also ls > fileName will write the results to a text file. Please help (6 Replies)
Discussion started by: rkaif
6 Replies

7. UNIX for Dummies Questions & Answers

How do I find files which are older than 30 days and greater than 1GB

Hi All, I know the separate commands for finding files greater than 30 days and finding files greater than 1GB. How do I combine these two commands? Meaning how do I find files which are > 1GB and older than 30 days? ;) (4 Replies)
Discussion started by: Hangman2
4 Replies

8. Shell Programming and Scripting

Trying to find files equal to and greater than

Hi Guys and Gals, I'm having some difficulty putting this check into a shell script. I would like to search a particular directory for a number of files. The logic I have is pretty simple: Find file named *.txt that are newer than <this file> and count them If the number of files is equal to... (4 Replies)
Discussion started by: bbbngowc
4 Replies

9. Shell Programming and Scripting

Important finding --- find files greater than 1 MB

as we can find file greater than 1 MB with find command as: find /dir -name '*' -size +1M find /dir/* -name '*' -size +1M but wats its doing is , its finding files only in current directory not in sub-directories. i want files from sub-directories too. Please help... Thanx in... (3 Replies)
Discussion started by: manoj_dahiya22
3 Replies

10. UNIX for Advanced & Expert Users

find formatted filename with date time

Hi, I operate and use HF radars along the California coast for ocean surface currents. The devices use Mac OS as the control and logging software. The software generates thousands of files a week and while I've used PERL in the past to solve the problems of finding files I come to realize some... (6 Replies)
Discussion started by: dpath2o
6 Replies
Login or Register to Ask a Question