1

How to read date from terminal and compare with current date

view story
linux-howto

http://stackoverflow.com – I want to know the appropriate way of reading date from terminal and comparing with current date using shell script, I have the below script, a=`date +%Y-%m-%d` while [ 1 ] ; do echo "Enter Date" read todate if [ $todate < $a ];then break; fi echo "todate greater than curDate" done it is not running as expected. Please help me. UPDATE Here is my final version, #! /bin/bash DATE=$(date '+%s') while [ 1 ] ; do echo "Enter Date[DD MM YYYY]:" read D M Y THIS=$(date -d "$Y-$M-$D" '+%s') if (( THIS < DATE )) ; then break (HowTos)