Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 11-05-2015, 04:30 AM   #1
LQ Newbie
Registered: Jul 2015
Posts: 2

Rep: Reputation: Disabled
How can I find files in Linux where filename contains datetime format


I need help on this. I have thousands of files in a directory with datetime format in filename. For example the file name like "operatingcapacity_10_2008.xls", "1337707002239_DiscountJune2012.pdf", "producer_cashout_report-2015-04-30-094409.xls" and "contractedFirmStorageCap.08182015_144505000.xls". So I want to fetch only those files whose name contains the datetime less than today-365 days. It's very urgent. Please help.


Last edited by pthakur; 11-05-2015 at 04:55 AM.
Old 11-05-2015, 04:43 AM   #2
Registered: Aug 2013
Location: Sweden
Distribution: Debian, Arch, Red Hat, CentOS
Posts: 764
Blog Entries: 3

Rep: Reputation: 366Reputation: 366Reputation: 366Reputation: 366
Originally Posted by pthakur View Post
It's very urgent. Please provide some solution.

[Deep breath]


If it is very urgent, then I suggest that you hire a consultant to do the work for you. We are not here to provide solutions, but rather to help you if you are stuck writing your own script/program/regular expression.

So, to summarize: please get back with an example of what you have tried in order to solve this problem, and we will do our best to help you out.

But, I'll give you this: upon a brief inspection it seems as there is no standard with regards to the dates. Apparently it can be "10_2008", "June2012", "2015-04-30" or "08182015" or pretty much anything. In other words, you have some work to do here. If it were me, I would start by excluding the files that contain "2015" since they are not wanted and work from there.

In other words. In a directory that looks like this ( is the script):
$ ls
I get this result simply by filtering out the files containing "2015" (and obviously skipping the script as well):

Best regards,

Last edited by HMW; 11-05-2015 at 05:15 AM.


linux command, shell scripting, unix

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Find files that they have the same filename but different extension. dimitriauxio Linux - Newbie 2 09-11-2013 01:10 PM
Finding files with filename format adshocker Linux - Newbie 4 10-28-2010 01:01 AM
[SOLVED] Simple Linux script to convert datetime format to UTC format shayno90 Linux - Newbie 10 10-09-2009 08:19 AM
Find/grep/wc command to find matching files, print filename and word count dbasch Linux - Newbie 10 09-14-2009 05:55 PM
comparing datetime format in php mohtasham1983 Programming 2 01-26-2006 07:54 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:40 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration