Question: SYST13416 Assignment#1 (shell scripting) Create a directory called ASSIGN1 in your home directory, and do everything for this assignment in this ASSIGN1 directory. Create a

SYST13416 Assignment#1 (shell scripting) Create a directory called ASSIGN1 in your home directory, and do everything for this assignment in this ASSIGN1 directory. Create a file in this directory called products in which you will put a few lines of data (5 to 10 lines) consisting of product number (6 digits), product name followed by product price. Each field should be separated by a comma. For example first line can be : 111111, blue pens, 1.99 (this file will be used in step 2). STEP 1: Create a Bash shell script (myscript) inside ASSIGN1 directory. This script should create a subdirectory called numbers inside the ASSIGN1 directory. If that directory already exists, it should delete the existing one and create a new one. Script should allow user to pass 3 numbers to this script when it runs. It should be one positional parameter, consisting of three digits (numbers). Make sure that the parameter/argument entered by the user consists of 3 numbers. If its not 3 numbers, then give appropriate error message and exit with exit status of 1. If the parameter entered was a 3 digit number, then display it. The script should check numbers and determine whether they are unique. For example, if the numbers passed to this script are 123, script should create file1, file2 and file3 (inside the numbers directory). If last 3 digits are 121, then create file1 and file2. List the files you have created. STEP 2: The script should now check for the existence of products file in ASSIGN1 directory. If it does not find that file, it should give an error message and exit. If the file does exist, it should display the contents of the file. Then it should cut the 2nd field (product name) from each line of the file (hint: use the cut command and use comma as the delimiter to pick the 2nd field). Capture the product names that are being cut into a separate file names. Then display the contents of this file names. Now the script should use the appropriate command to count the number of lines in the names file and display a message indicating how many products there are in the products file. For example, if you had 6 products in your products file, this message should say I have 6 products in my product file by using the number it obtained from counting the lines. STEP 3: Run and test your script multiple times.

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!