Search iEntry News

UnixProNews
SecurityProNews
ITmanagement












User Friendly Date Script

By A.P. Lawrence
Expert Author
Article Date: 2003-03-31

Setdate

The "setdate" is just a more user-friendly front end to changing the date and time:


echo -n "Enter Date or leave blank for `date +%m/%d/%y`: " 
read mydat
echo -n "Enter Time or leave blank for `date +%H:%M`: " 
read mytime
if [ "$mydat" != "" ]
then
      mmdd=`echo $mydat | sed 's////g;s/..$//'`
      yr=`echo $mydat | sed 's////g;s/^....//'`
else
      mmdd=`date +%m%d`
      yr=`date +%y`
fi
if [ "$mytime" != "" ]
then
      newtime=`echo $mytime | sed 's/://g'`
else
      newtime=`date +%H%M`
fi
date "$mmdd$newtime$yr"





This script works on Linux, SCO and most other Unixes.

Please read this disclaimer
Copyright and reprint info

About the Author:
A.P. Lawrence provides SCO Unix and Linux consulting services http://www.pcunix.com



Newsletter Archive | Article Archive | Submit Article | Advertising Information | Resources | About Us | Contact

UnixProNews is an iEntry, Inc. ® publication - 1998-2008 All Rights Reserved Privacy Policy and Legal