1. Introduction

    System Information

  2. Inter-Process Communication
  3. Signals

    Programming in Various Environments

  4. Script Programming
    1. Script Variables
    2. Test Conditions
    3. Control and Iteration
    4. Commonly used Programs
    5. Shell Capabilities
    6. Example looping script
    7. Example using Variables
    8. Example working with files
    9. Example install script
  5. C and C++ Programming
    1. POSIX System Capabilities
    2. More POSIX
    3. Threads
    4. Mutexes
    5. An example viewmod program
    6. An example serial program
  6. X Programming
  7. Debugging
  8. Credits

Examples

Adjust time program:

datenow=`date +%m%d%Y`
month=`echo $datenow | cut -b1-2` 
day=`echo $datenow | cut -b3-4`
year=`echo $datenow | cut -b5-8`
echo $month-$day-$year:$1
days=30
adj=$1
while [ $adj -gt 0 ]
do
   case $month in
     04 | 06 | 09 | 11 | 4 | 6 | 9)
      days=`expr 30`
      ;;
     02 | 2)
      days=`expr 28`
      ;;
     * )
      days=`expr 31`
      ;;
   esac
   if [ $adj -ge $day ]; then
      if [ $month -gt 1 ]; then
#         month=`printf "%2d" $(expr $month - 1)`
	  month=`expr $month - 1` 
      else
         year=`expr $year - 1`
         month=12
      fi
      if [ $adj -ge $days ]; then
         adj=`expr $adj - $days`
      else
	 day1=$day
         day=`expr $days + $day - $adj`
         adj=0
      fi
   else
      day=`expr $day - $adj`
      adj=0
   fi
if [ `expr length $month` -lt 2 ]; then
  month=`echo 0$month`
fi
if [ `expr length $day` -lt 2 ]; then
  day=`echo 0$day`
fi
echo $month-$day-$year:$1:$adj
done
echo $month-$day-$year:$1:$adj
yy=`echo $year | cut -b3-4`
echo $month$day"0000"$yy
touch $month$day0000$yy /tmp/time.then