LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-03-2012, 05:21 AM   #1
muralimunna
LQ Newbie
 
Registered: Apr 2012
Posts: 4

Rep: Reputation: Disabled
Date comparisons ...


how can i compore date in linux....using timestamps
 
Old 05-03-2012, 05:22 AM   #2
muralimunna
LQ Newbie
 
Registered: Apr 2012
Posts: 4

Original Poster
Rep: Reputation: Disabled
how can i compare 10/01/2009 with current date
 
Old 05-03-2012, 08:15 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,411

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
Read this to see how to get current date in required format http://linux.die.net/man/1/date, then split each string using either bash built-ins or eg cut or awk and compare each field separately.

Show us your code if you get stuck.
 
1 members found this post helpful.
Old 05-03-2012, 11:18 PM   #4
jlinkels
Senior Member
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 4,703

Rep: Reputation: 731Reputation: 731Reputation: 731Reputation: 731Reputation: 731Reputation: 731Reputation: 731
Comparing dates is best done using timestamps. Refer to the man page chrism01 gave you. Convert a date to a time stamp and do the arithmetic.

jlinkels
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
two comparisons GerardM Linux - Newbie 6 06-15-2009 09:41 PM
date comparisons and increments in bash elinenbe Programming 5 10-19-2007 12:40 PM
string comparisons ricmon Programming 18 06-12-2007 11:31 AM
CPU comparisons lothario Linux - Hardware 2 12-11-2006 09:25 PM
Firewall Comparisons Please floppywhopper Linux - Security 11 10-02-2004 08:42 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:33 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration