[NTLUG:Discuss] verify that a text string is a valid date.
Richard Geoffrion
ntlug at rain4us.net
Sat Feb 4 10:27:43 CST 2006
Leroy Tennison wrote:
>Chris Cox wrote:
>
>
>
>>Richard Geoffrion wrote:
>>
>>
>>
>>
>>>I'm trying to do something but I don't know what it is called.
>>>
>>>I want to check to see if the first 10 characters of a file is a vaild
>>>date...eg 2006-02-01 and if it IS..then I want to continue the process.
>>>
>>>What am I trying to do in bash(or other utility terms)? I don't know
>>>the name of what I'm trying to do so I'm finding it difficult to search.
>>>
>>>
>>>
>>>
>>$ mydate="2006-02-01"
>>$ date -d "$mydate"
>>Feb 28 00:00:00 CST 2006
>>
>>
>>
>This has to be the most elegant solution I have seen (I was going to
>suggest awk but no need when an existing program can do all the tests
>for you).
>
>
>
>
Yes..that WAS a very concise solution. Thanks again, Chris. Now, what
I have on my system is "date (GNU sh-utils) 2.0". This is on a
Slackware 8.1 box. So the question now becomes... what are the
ramifications of upgrading the coreutils on that box? Anything? I
found http://ftp.gnu.org/pub/gnu/coreutils/. and expect that I just need
to download the source and compile it into my environment -- I just
don't know what kind of issues upgrading that will bring to the system.
For instance... ps2pdf was converting a file incorrectly. Once I
upgraded it..it stopped converting the file altogether.
So anyway...I'll probably go get the coreutils and stare at them
awhile. I'll make sure I have my old slack coreutils package handy.
Maybe I'll wait till after the superbowl (are we allowed to say that
here...or do we have to pay royalties?) to do the upgrade.. Just in case
anything untoward happens.
--
Richard
More information about the Discuss
mailing list