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

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

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