Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 $

------

image text in transcribed

**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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

A 300N F 30% d 2 m Answered: 1 week ago

Answered: 1 week ago

Question

1. Identify three approaches to culture.

Answered: 1 week ago

Question

2. Define communication.

Answered: 1 week ago

Question

4. Describe how cultural values influence communication.

Answered: 1 week ago