Bash - compare 2 dates

How can i compare 2 dates?

└─(~)-> date
Thu Apr  5 06:13:35 UTC 2007

This one, with a pre-given one (pregivendate="5 May 2007")
(i just want to compare the day, month and year)
Something like ...
if date is greater than the pregivendate; then stop else do something

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

test `date +%Y%m%d` -gt 20070505 && do something
rares_dumitrescuAuthor Commented:
and .. at the end .. how can i split 20070505 into 2007 / 05 / 05 ?
date +'%Y / %m / %d'
Bootstrap 4: Exploring New Features

Learn how to use and navigate the new features included in Bootstrap 4, the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites.

rares_dumitrescuAuthor Commented:
ah .. not the date .. the other one
here is the script

date=`date +%m%d%Y`

if [ "$date" -gt "$expd" ]; then
echo "Your script has expired in: !here i want the 02052007 splitted into 02 / 05 / 2006! (Month /  Day / Year)"
date=`date +%Y%m%d`
if [ "$date" -gt "$expy$expm$expd" ]; then
echo "Your script has expired in: $expm / $expd / $expy! (Month /  Day / Year)"

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rares_dumitrescuAuthor Commented:
thanx ozo, you've been great, like always :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.