LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


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

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


Hi,

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.

Thanks

Last edited by pthakur; 11-05-2015 at 05:55 AM.
 
Old 11-05-2015, 05:43 AM   #2
HMW
Member
 
Registered: Aug 2013
Location: Sweden
Distribution: Debian, Arch, Xubuntu, Manjaro
Posts: 745
Blog Entries: 3

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

Thanks
[Deep breath]

Hi!

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.

Edit:
In other words. In a directory that looks like this (exclude.sh is the script):
Code:
$ ls
1337707002239_DiscountJune2012.pdf
contractedFirmStorageCap.08182015_144505000.xls
exclude.sh
operatingcapacity_10_2008.xls
producer_cashout_report-2015-04-30-094409.xls
I get this result simply by filtering out the files containing "2015" (and obviously skipping the script as well):
Code:
./exclude.sh 
1337707002239_DiscountJune2012.pdf
operatingcapacity_10_2008.xls

Best regards,
HMW

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


Reply

Tags
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 02:10 PM
Finding files with filename format adshocker Linux - Newbie 4 10-28-2010 02:01 AM
[SOLVED] Simple Linux script to convert datetime format to UTC format shayno90 Linux - Newbie 10 10-09-2009 09:19 AM
Find/grep/wc command to find matching files, print filename and word count dbasch Linux - Newbie 10 09-14-2009 06:55 PM
comparing datetime format in php mohtasham1983 Programming 2 01-26-2006 08:54 AM


All times are GMT -5. The time now is 10:27 PM.

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