Question: This is an individual assignment. You must submit your own work and you are solely responsible for your submission. Make sure you understand what are

This is an individual assignment. You must submit your own work and you are solely responsible for your submission. Make sure you understand what are required for each question. There are 3 questions in this assignment.
This assignment will contribute 30% towards your overall course marks.
Question 1: Shell Scripting (Max Mark: 20/100)
This question requires you to write a shell script for bash or zsh.
Task: Write a bash (or zsh) shell script that accepts exactly two arguments from the command-line. The first argument is meant to be a filename of a text file and the second one is the name of a directory. This script should perform the following:
a) Display an appropriate error message and terminate if the number of arguments is not exactly 2.
b) If the file (specified in argument 1) does not exist, then display an appropriate error message and terminate.
c) Otherwise, save all the lines in that file that contains the word special in a file called special.txt in the directory specified as argument 2. If this directory does not exist in the current directory, then create it.
d) If the file special.txt already exists in the directory specified, then those lines of text extracted from argument 1 should be appended to special.txt.
Submission Requirement: Submit only your script file. Your script file MUST be named extract.sh
Your script file should be documented with appropriate comments. Make sure your name and student ID are at the top of the file.

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 Programming Questions!