![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Displaying lines of a file where the second field matches a pattern | LordJezoX | Shell Programming and Scripting | 3 | 05-20-2009 09:00 AM |
| replace a column in a file if it matches certain pattern | Krrishv | Shell Programming and Scripting | 6 | 03-12-2009 05:16 AM |
| Print line if first Field matches a pattern | Raynon | Shell Programming and Scripting | 2 | 01-08-2009 06:07 AM |
| awk to count pattern matches | npatwardhan | Shell Programming and Scripting | 16 | 12-13-2008 12:20 PM |
| Extract if pattern matches | Raynon | Shell Programming and Scripting | 20 | 10-29-2007 04:44 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
get value that matches file name pattern
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 |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|