I have a file with a list of dates in the format below: yyyymmddhhmmss
20150608141617
20150608141345
20150608141649
20150608141506
20150608141618
20150608141545
Would like to validate the correctness of these dates in case there are errors during generation in a previous process.
Correctness means that there are no spaces,length is 14 characters and the date is valid i.e. no date like 20151508141545.
Is this possible in perl or bash?
The following will do what you need, using a quick check for length, then the built-in
Time::Piecemodule to validate correctness.To change this code to read from a file, above the
for()loop, write:Then in the
for()loop, change<DATA>to<$fh>and delete__DATA__and everything below it.