[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Command-line-interface (CLI) calculator to work out the difference between 2 dates



On 08/25/08 20:34, s. keeling wrote:
Ron Johnson <ron.l.johnson@cox.net>:
 On 08/24/08 11:32, Rick Pasotto wrote:
Why pipe it to bc? Keep it in the shell:

$ echo $[$[$(date -d 20090824 +%s) - $(date -d 20080724 +%s)] / 86400]
396
 [snip]

One stylistic reason for piping to bc is that some people think that bash's $[] syntax gets too hard to read if you nest it too much.

I've been running *nix on my home boxes since '93, and I've never even
seen that syntax.  That's a bashism, I hope?

Yes.  And a relatively modern one at that.  Somewhere in the 3.x series.

I do own, and have studied, O'Really's Learning the bash shell.

--
Ron Johnson, Jr.
Jefferson LA  USA

"Do not bite at the bait of pleasure till you know there is no
hook beneath it."  -- Thomas Jefferson


Reply to: