extracting substring from a filename [message #315765] |
Tue, 22 April 2008 13:30 |
beetel
Messages: 96 Registered: April 2007
|
Member |
|
|
Hi,
I am a beginner in Unix so please bear with me...
I have a directory which has files in format: RECF-YYYY-MM-DD-input. For example, RECF-2008-02-25-input. I need to extract the YYYYY-MM-DD substring from this filename and convert that into date and compare it with a date. How do I do that?
For instance, I have a directory with the following files:
RECF-2008-02-21-input
RECF-2008-02-22-input
RECF-2008-02-23-input
RECF-2008-02-24-input
I need to get the files whose date substrings are greater than 2008-02-22 (Feb 22, 2008) which are RECF-2008-02-23-input and RECF-2008-02-24-input in the examples above. Please help
Thanks in advance.
|
|
|
|
|
Re: extracting substring from a filename [message #316102 is a reply to message #316099] |
Wed, 23 April 2008 14:43 |
andrew again
Messages: 2577 Registered: March 2000
|
Senior Member |
|
|
by the way... Using touch & newer allows you to have fine granularity with time.
find -mtime allows integers, so 24 hr is your granularity. As you are interested in the date contained in the filename - not the file date, then you need to work with the filename and the string sort like mentioned.
|
|
|