LinuxQuestions.org
Review your favorite Linux distribution.
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, 04: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, 04: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, 07:15 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 7.7 (?), Centos 8.1
Posts: 18,238

Rep: Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712
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, 10:18 PM   #4
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
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 08:41 PM
date comparisons and increments in bash elinenbe Programming 5 10-19-2007 11:40 AM
string comparisons ricmon Programming 18 06-12-2007 10:31 AM
CPU comparisons lothario Linux - Hardware 2 12-11-2006 08:25 PM
Firewall Comparisons Please floppywhopper Linux - Security 11 10-02-2004 07:42 PM

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

All times are GMT -5. The time now is 03:22 PM.

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
Open Source Consulting | Domain Registration