Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Instructions: Your assignment is to write a shell script that swaps the contents of two files. The shell script should be called swap.sh. The initial

Instructions: Your assignment is to write a shell script that swaps the contents of two files. The shell script should be called swap.sh. The initial requirements described in this paragraph will only be stated in this assignment, but will be required in all of the other shell script assignments this semester. In all of your shell script assignments, be sure to (1) put the comment at the beginning of the script to indicate to the system that the Bourne shell is to be used, (2) put comments after that line to identify yourself, the assignment and to describe the general purpose of the script, (3) put an appropriate comment before each block of commands in the script, (4) exit with a status of zero when the script was able to correctly accomplish its task, and (5) print an appropriate error message and exit with a nonzero status when the script was not able to accomplish its task. The swap.sh script should take two arguments as input that indicate the two files to be swapped. You should check that the proper number of arguments have been passed and that the filenames passed on the command line have the proper permissions set. You should also check that any temporary files used during the execution of the script do not exist. If any of these checks fail, then print an appropriate error message and exit the script with a status of one. If all of the checks pass, then swap the two specified files and print a message indicating that the two files have been swapped. Example Session: % swap tmp1 tmp2 The files tmp1 and tmp2 have been successfully swapped.

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_2

Step: 3

blur-text-image_3

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

Readings In Database Systems

Authors: Michael Stonebraker

2nd Edition

0934613656, 9780934613651

More Books

Students also viewed these Databases questions