Question: With Unix shell scripts, write a copy file program called mycp to prompt for arguments if none are supplied. A typical execution of the

With Unix shell scripts, write a copy file program called "mycp" to prompt for arguments if none are supplied. A typical execution of the modified version should look like this: ------

$ mycp Source file name? voucher Destination file name? voucher.sv $

------

With Unix shell scripts, write a copy file program called "mycp" to

**edit**

a program needs to be written for copying files. after running the program, a prompt needs to appear: Source file name?: Then the user enters the file they want copied. If it goes through, Destination file name?: must appear for where the source file needs to be copied to, all while using the same arguments from the sample code--- the sample code is NOT the code being used- but just for reference

$ cat ny cp # Copy a file. final version # Add file to copylist if file doesn't already exist # or if user says it's okay to overwrite # save this for later use numargs=$# filelist= copylist= if [ -e "Stofile ] then echo "$tofile already exists; overwrite (yeso)? C read answer # Process the arguments, storing all but the last in filelist if [ $answer' = yes ] then copylist="$copylist Sfron while ($#" .gt 1] do filelist="$filelist $10 shift else copylist="$copylist $from" done fi done to="$10 # Now do the copy .. first make sure there's something to copy # If less than two args, or if more than two args and last arg # is not a directory, then issue an error message if then n "Scopylist" ] cp $copylist $to # proceed with the copy a 1.d "$to ] if [ "$numargs" .lt 2.0 "$numargs .gt 2 then echo "Usage: mycp file1 file2" mycp file(s) dir" exit 1 echo. # Sequence through each file in filelist for from in Sfilelist do # See if destination file is a directory if (d'Sto' ] then tofile="$to/$(basename $from)" else tofile="$to" $ cat ny cp # Copy a file. final version # Add file to copylist if file doesn't already exist # or if user says it's okay to overwrite # save this for later use numargs=$# filelist= copylist= if [ -e "Stofile ] then echo "$tofile already exists; overwrite (yeso)? C read answer # Process the arguments, storing all but the last in filelist if [ $answer' = yes ] then copylist="$copylist Sfron while ($#" .gt 1] do filelist="$filelist $10 shift else copylist="$copylist $from" done fi done to="$10 # Now do the copy .. first make sure there's something to copy # If less than two args, or if more than two args and last arg # is not a directory, then issue an error message if then n "Scopylist" ] cp $copylist $to # proceed with the copy a 1.d "$to ] if [ "$numargs" .lt 2.0 "$numargs .gt 2 then echo "Usage: mycp file1 file2" mycp file(s) dir" exit 1 echo. # Sequence through each file in filelist for from in Sfilelist do # See if destination file is a directory if (d'Sto' ] then tofile="$to/$(basename $from)" else tofile="$to

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!