Add a -n option to mycp that suppresses the normal check for the existence of the destination files
What will be an ideal response?
# mycp -- copy a file with safety checks
nocheck=0
if [ "$1" = "-n" ] ; then
nocheck=1 # don't check for file existence
shift
fi
if [ "$#" -ne 2 ] ; then
echo "Source file name? \c" ; read from
echo "Destination file name? \c" ; read to
else
from="$1"
to="$2"
fi
# See if the destination file already exists
if [ $nocheck -eq 1 -a -e "$to" ] ; then
echo "$to already exists; overwrite (yes/no)? \c"
read answer
if [ "$answer" != yes ] ; then
echo "Copy not performed"
exit 0
fi
fi
# Either destination doesn't exist, "yes" was typed
# or the user specified -n to bypass the test
cp $from $to # proceed with the copy
You might also like to view...
When a symbol can be formatted with such text features as Bold, Italics, and Font Color the symbol is a(n) ________
A) shape graphic B) picture graphic C) character graphic D) text graphic
A centralized Apple place to find system and application logs and messages is the ________
Fill in the blank(s) with correct word