![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| calculate the date of next satureday of current date. | rinku | Shell Programming and Scripting | 3 | 09-02-2008 08:05 PM |
| Get date and time for past 1 hour from current date | spch2o | Shell Programming and Scripting | 5 | 08-29-2008 01:32 AM |
| Extracting date-time from file. | skumar11 | Shell Programming and Scripting | 7 | 09-06-2007 01:45 PM |
| File date vs Current date | trexlim | Shell Programming and Scripting | 4 | 05-04-2007 06:35 PM |
| how to give current date in file name? | simurg11 | UNIX for Dummies Questions & Answers | 3 | 05-10-2005 06:09 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Perl: Extracting date from file name and comparing with current date
I need to extract the date part from the file name (20080221 in this ex) and compare it with the current date and delete it, if it is a past date.
$file = exp_ABCD4_T-2584780_upto_20080221.dmp.Z really appreciate any help. thanks mkneni |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Code:
m/(\d+)\./ |
|
#3
|
|||
|
|||
|
you can then use Date::Calc:
|
|
#4
|
|||
|
|||
|
Thank you both. I am still lost. I am not talking about the mtime of the file. I need to extract date portion from the file name (which is in YYYYMMDD format) and compare it with the current date.
|
|
#5
|
|||
|
|||
|
Code:
if ($friendly_dancing_file_name =~ m/(\d+)\./) {
print "oh goody, looks like the file's date is $1\n";
print "abort, return, continue, are you sure?\n";
<>;
}
|
|||
| Google The UNIX and Linux Forums |