Solutions

1.	#!/bin/ksh
	# Print files one per line, identify as file or directory
	for f in *
	do
	   if [ -d $f ] ; then   # If it is a directory
	      echo $f directory
	   else                  # else it is a file
	      echo $f file
	   fi
	done


2.	#!/bin/ksh
	# Echo command line parameters using $1 and shift.
	while [ $# -gt 0 ]
	do
	   echo $1
	   shift
	done

3.	#!/bin/ksh
	# mycp will cp a file.  If destination exists, prompt for
overwrite.

	if [ $# -ne 2 ] ; then  # check for exactly two arguments
	   echo "Usage: $0 source dest"
	   exit 1
	fi

	if [ -f $2 ]; then
	   echo "$2 already exists: overwrite? (y/n) \c"
	   read a
	   if [ "$a" = y ] ; then
	      cp $1 $2   # overwrite dest
	   fi
	else
	   cp $1 $2   # dest did not already exist, just do copy
	fi

4.	#!/bin/ksh
	# File: case2
	while :
	do
	   echo "Enter someone's name: \c"
	   read name
	   case $name in
	     brenda) echo "Drives a vette, lives in Brentwood."
	             echo "Loves cats."
	     ;;
	     bobby)  echo "Drives a jeep, lives in Twin Peaks."
	             echo "Loves dogs."
	     ;;
	     julie)  echo "Rides a Harley, lives in Palm Springs."
	             echo "Loves freedom."
	     ;;
	     johnny) echo "Rides a mountain bike, lives in Moab."
	             echo "Loves nature."
	     ;;
	     quit) exit
	     ;;
	     *) echo "Don't know this person."
	     echo "Try again."
	     ;;
	   esac
	done

