#!/bin/ksh
# This script will use cp to copy one file to another, but
# it will first check to see if the destination file exists.
# If so, it will ask the user if overwriting is OK.

# Check for exactly two arguments
if [ $# -ne 2 ] ; then
   echo "Usage: $0 f1 f2"
   exit
fi

# Make sure $2 is a regular file
if [ -f "$2" ] ; then
   print -n "$2 already exists: overwrite? (y/n) "
   read a
   if [ "$a" = "y" ] ; then
      cp "$1" "$2"
   fi
else
   cp "$1" "$2"   # $2 is not a regular file, so just do the copy
fi	
