CYSE270 Assignment 8

Task A (Correct script (25 points) + result/output after executing the script (25 points)-

Conditional Statement

Write a shell script using nano or vi editor (eg, vi scriptname.sh) like below, that performs

the following task:

1. Add the Shebang (#!/bin/bash) as the first line in your script.

2. Read a number using read function

3. Using the if statement, check if the input number is greater than 10, then print the message “Input number is greater than 10”.

4. If the number is not greater than 10, then print the message, “Input number is not greater than 10”.

(Your script should result into the output similar to this sample screenshot after executing as shown below)

Task B (Correct script (25 points) + result/output after executing the script (25 points) –

Shell Script to Create a new file

Write a shell script using nano or vi editor (eg, nano scriptname.sh) like below, that

performs the following task:

1. Add the Shebang (#!/bin/bash) as the first line in your script.

2. Reads the name of the file to check for a filename that exists.

3. Check whether the given input is a directory or regular file.

4. If the input is a directory and exists, then display the message “Directory exists”.

5. If the input is a regular file, then display the message “It is a regular file, and the file exists” and display the contents of the file.

6. If the given input name in step-1 doesn’t exist, then create the new file with the given name in step-1.

Leave a Reply

Your email address will not be published. Required fields are marked *