Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Jan 212011
 

Simple date calculation using date command

Answer:

Date command is useful to calculate date, e.g. Assume today is 2011-01-15

1. Find a date in the past, e.g. 60 days ago

# date --date='60 days ago' "+%Y-%m-%d"
2010-11-16

2. Find a date in the future, e.g. 60 days in the future

# date --date='60 days' "+%Y-%m-%d"
2011-03-16
Dec 262010
 

Display timestamp information in command history

Answer:

When using the history command, it only shows the command number and the command itself. But sometimes it is useful to know when this command was executed, i.e. the timestamp. To do so, following the instructions below:

# export HISTTIMEFORMAT='%F %T '

Then type history again

# history
..
 260  2010-12-23 19:22:07 ls
 261  2010-12-23 19:22:07 pwd
...

That's all.