E-Mail:
Get our new Windows 7 eBook (PDF) for $7 with 70+ Tips. Download Now!

How do you do date math in Linux?

  • No Related Post

While modern Linux operating systems have more capabilities than you can shake a bag full of sticks at, there are still some tasks that aren’t as easy as you’d like. One of the most common challenges is date math. What’s the date 37 days from today, or 496 days ago? The question I received asked about solving this puzzle within a shell script, but while it’s possible, it’s quite a bit easier to produce a succinct C program to do the work instead:

&nbps;   Date Math in a Linux shell script?

It’s always fun to write an actual compiled program after spending so darn much time writing lightweight shell scripts too.

[tags]linux,unix,shell script,c programming language,date math[/tags]

One Comment

Hi, you also can use date for this :)

Example:
date -d’120 seconds ago’
for forward just simply
date -d’120 seconds’

you also can do this with years minutes.

Cheers,
Sea-you

What Do You Think?

 
35 queries / 0.345 seconds.