title: How to read date from terminal and compare with current date
body: <p>I want to know the appropriate way of reading date from terminal and comparing with current date using shell script,</p>
  
  <p>I have the below script,</p>
  
  <pre><code>a=`date +%Y-%m-%d`
  while [ 1 ] ; do
          echo "Enter Date"
      read todate
      if [ $todate &lt; $a ];then
          break;
      fi
      echo "todate greater than curDate" 
  done 
  </code></pre>
  
  <p>it is not running as expected. Please help me.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Here is my final version,</p>
  
  <pre><code>#! /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 &lt; DATE )) ; then
          break
      fi
  done
  </code></pre>
  
  <p>Thanks everyone!</p>