ksh - examples
## ksh - examples 
## ksh_examples.txt

## set kshell at begining of script
#!/bin/ksh

## extract date 
DAY=`date +%a%m%d`
LOGFILE=/usr/local/bin/log/fullexp_${DAY}.log         
                
## create a unique file name, use ${1:-$$} which is the PID of the parent script 
export FILENAME=file_${1:-$$}.tmp

## create a counter
cnt=1
((cnt+=1))

## sed: due a substitution 
PATH=`echo $PATH | sed "s;$OLDHOME/bin;$ORACLE_HOME/bin;g"`
ORACLE_BASE=`echo $ORACLE_HOME | sed "s;/u01/home/oracle/product/734;/u01/home/oracle;" | sed "s;/oraclen3/d01/app/oracle/product/816;/oraclen3/d01/app/oracle;"` ; export ORACLE_BASETTT

## for loop: 
for i in 1 2 3 4 5 
do
	print $i
done

## read a field sequentially from a file
cat /etc/oratab | while read LINE
do
  case $LINE in
  \#*)	;;	# comment-line in oratab
    *)
     dbarray[${subscript}]=`echo $LINE | awk -F: '{print $1}'`
  esac
done

## list all lines of all files containing a string (allo)
grep allo *

## case statement
# Check for the number of passed arguments
case $# in 
0)
     echo "You need to pass the name of the utlreport files to parse as a parameter for this script to work"
     echo "ERROR - invalid parameter "
     exit 1
;;
1)
     FILES_TO_PARSE=${1}
;;
2)
     if [[ ${2} = "truncate" ]]
     then LOADOP="TRUNCATE"
     else echo "Invalid 2nd parm"
          exit 1 
     fi
;;
*)
     echo "More than 2 parms passed to this script "
     echo "ERROR - invalid number of parameters "
     exit 1
;;
esac