All pastes #204892 Raw Edit

Something

public text v1 · immutable
#204892 ·published 2006-10-16 10:34 UTC
rendered paste body
LOGFILE=exercise-2-2.log

ANS_BOOL=true


while $ANS_BOOL
do
  echo "Do you want to overwrite the log file?"
  echo "Type in: Yes or No"
  read ANS

  if [ "$ANS" -eq "YES" || "$ANS" -eq "NO" ]
  then
     ANS_BOOL=false
  else
     ANS_BOOL=true
  fi
  break
done

if [ "$ANS" -eq "No" ]
then
  touch $LOGFILE

  echo " " >> $LOGFILE

  date >> $LOGFILE
  who >> $LOGFILE
  uptime >> $LOGFILE
  break
fi

if [ "$ANS" == "Yes" ]
then
  touch $LOGFILE

  echo " " > $LOGFILE

  date >> $LOGFILE
  who >> $LOGFILE
  uptime >> $LOGFILE
  break
fi

unset LOGFILE ANS_BOOL ANS
exit 0