Thursday, January 12, 2012

Compare Time stamp In Shell Script year, Month day, Hour, Minute, Second

Linux How To Compare the timestamp
1) Using Date command we can compare
2) In these format i used just simple numberical comparsion and it'wll work for timestamp comparsion.
Year-Month-day-Hour-Minute-second.
3)syntax
Date1=`date +%Y%m%d%H%m%S`;
Date2=`date +%Y%m%d%H%m%S`;
if(Date1 Condition Date2)
date +
%y - Year in Two Digit
%Y - year in Four Digit
%m - month in Numberic
%d - Date
%H- Hours
%h - Month in String

For Example
current_time=`date +%Y%m%d%H%M%S`;
Year-Month-Date-Hour- Minute-Second
if [ "$login_time" -lt "$current_time" ]; then
How To Compare  Time stamp in Shell Script.

0 comments:

Flag counter

free counters