I don't disagree with anything you have said, however...
Quote:
Originally Posted by sb008
Based on the fact that was stated that the format of the files is:
filename<date>.dat
the regular expression would be strict enough, since it's fair to assume that whatever program produces these output files produces them with a valid date in the file name.
If you're going to assume that whatever program produces these output files produces them with a valid date in the file name, 1) you've made your regular expression unnecessarily strict; that is, you could have just as easily used filename[0-9][0-9][0-9][0-9][0-9][0-9].dat (although less reasonable, it's certainly easier to type), and 2) you're assuming the original poster's request is irrelevant, since his requirement was to "match the filenames like so, ls filename[01-12][01-31][00-99].dat thus guaranteeing [his] date format".
Quote:
Originally Posted by sb008
If other files are around with a similar format, your regular expression, even though it's more strict, would be as useless as mine. Unless ofcourse you promote the filosophy that a statement is better if it has a smaller chance on producing errors.
In most cases here on unix.com, I do promote that philosophy.
Quote:
Originally Posted by sb008
The only valid option, if files with similar patterns are around, is to isolate the date part from the filename and use e.g. a date conversion command/tool on that pattern and test for the return code.
I agree, and that is something I have considered. However, I don't know of one offhand, and although I could write one, unless you can suggest an existing one to me, I can not offer it.