E-Mail:
Author Avatar

How do you do date math in Linux?

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: , , , ,

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?

 


Anti-Spam Image

Want to Start a Blog Here for Free?

Are you an expert in one subject or another? If your goal is to help others and dispense hard-earned information back to the community, stake a claim on your very own Lockergnome blog today! You can write about anything - no matter the topic. Sign-up to start blogging!

Author Avatar
Interview, Linux, Misc - Dec 19, 2007

KOffice vs OOXML: Practical, Not Political

Author Avatar
Myths - Dec 3, 2007

5 Myths That Stymie Linux Growth

Author Avatar
Just Ask Matt - Linux Edition - Nov 20, 2007

Default Sound Card Not Sticking In Ubuntu!