Question: Bourne Shell Script $ hw2 file1.c cprogs file2 memos The above command would do the following, if both subdirectories exist: Move file1.c to immediate subdirectory

Bourne Shell Script

$ hw2 file1.c cprogs file2 memos

The above command would do the following, if both subdirectories exist:

Move file1.c to immediate subdirectory cprogs

Move file2 to immediate subdirectory memos

Implementation: You must implement this script using a while loop that contains shift commands to access the filename and subdirectory arguments (NOTE: $# will change every time you use the shift command).

The script should first verify that an EVEN number of arguments (2 or more) were entered. If not, use a HERE document to display an error message and the correct argument format, and then exit the script with exit code 1.

Then, before moving each file, the script should verify that the both the named file and the named subdirectory exist.

- If the file does not exist, display an error message which includes the name of the file that does not exist.

- If the subdirectory does not exist, display a message stating which subdirectory does not exist and saying which file was not moved.

- If both the file and the subdirectory exist, move the file and display a message confirming that the file was moved and to where.

Shift and loop until all file/subdirectory pairs have been processed

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!