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

Computer Science & Information Technology

You might also like to view...

Because it is common for Web designers to want different tables on their Web pages to have different attributes, this is a perfect opportunity to make use of style ____________________.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

People in the higher economic brackets tend to prefer and respond favorably to ___________.

a. simple, bright hues b. darker, less saturated hues c. simple, less saturated hues d. dark, dull hues

Computer Science & Information Technology

Which IPS response to an attack can do the most damage?

A. None of the options B. Dropping packets C. limiting suspicious traffic to a certain percentage of the total bandwidth and dropping packets D. limiting suspicious traffic to a certain percentage of the total bandwidth

Computer Science & Information Technology

________ is a software that is completely free to use without any specified time restrictions.

A. Subscription software B. Open source software C. Shareware D. Freeware

Computer Science & Information Technology