Hi
I have files with names that contain the date in several formats as, YYYYMMDD, DD-MM-YY,DD.MM.YY or similar combinations.
I know if a file fits in one pattern or other, but i don�t know how to extract the substring contained in the file that matches the pattern.
For example, i know that
file.21-10-2009.log.txt
matchs *[0-9][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9]*.log.txt pattern.
Also
srv2.log.01.26.09.log.gz
matchs a different pattern:
*[0-9][0-9].[0-9][0-9].[0-9][0-9]*.log.gz
So i know each file format because i know its pattern, but how can i extract in a general way valid for any of this patterns the day,month or year from this?
Or said in a different way, if i�m given a file pattern and a file matching it, how can i divide file name to extract each date field according to that pattern?
Thank you