You are not logged in.
Pages: 1
To compare two dates+times* in bash I have always used date +%s and compared the resulting strings. Is there a better way to do it? Thanks.
* As in "is date+time Y after date+time X?"
But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner
Offline
@alphainer: I can't think of any other way. Personally, I'd advise to use a proper language with real data types (e.g. Python or Ruby) as soon as you need more than a handful date and time calculations.
Offline
@alphainer
As opposed to whom?
Most of the scripts I write don't warrant a real language. Plus I like the portability I get with bash, even if some operations are pretty fugly.
Thanks though.
But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner
Offline
I'd say, anything beyond executing some scripts warrants a proper language, meaning real types, a proper module system, and a comprehensive standard library. Bash is just not worth the hassle, not even with respect to portability. Python, Perl and Ruby are available on virtually any Linux system, either pre-installed, or in the package repositories. In turn, Bash isn't pre-installed on various Unix derivates.
Offline
Years ago I wrote a bash script to build a thumbnail gallery webpage for a local directory structure of torrents. For each torrent, it created the thumbnail of an image with the same name, scraped torrents to get seeders/leechers, parsed a text file of urls and added links below the image with special favicons for commonly linked sites.
That was a hassle, and I have been afraid to look at the script since I stopped using it. But the page it produced was pretty sweet.
Most of the scripts I write are a bit more down-to-earth than that though.
Last edited by alphaniner (2012-04-25 18:50:02)
But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner
Offline
Pages: 1