title: How to display the date value assigned variable outside the loop in shell script
body: <p>I following code, I am reading a file from reverse order and comparing the dates,In side the if condition I am trying to assign the date value in one variable.In the 'if' condition  value is displaying properly.
  If I am trying to display the variable  out side the loop, value is not displaying.</p>
  
  <pre><code>previousDay=`date +"%Y-%m-%d" -d "-1 day"`
  tac logfile.txt |
  (
  while read line
  do
  finish_time=`echo $line | sed -e 's/\([0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]\).*/\1/'`
  file_content_date=`date -d "$finish_time" +%Y%m%d`
  comparison_prev_date=`date -d "$previousDay" +%Y%m%d`
  if [ $comparison_prev_date -ge $file_content_date ]; then
  comparison_end_date=`date -d "$file_content_date" +%Y%m%d`
  break
  fi
  done
  )
  echo $comparison_end_date
  </code></pre>