Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

CIT 112 Hands-on Application Activity Week 10 1. Chapter 27 Flow Control: Branching with if 1.1 Create a BASH script called script1.sh which takes in the name of a month (e.g. Jan, Feb, Mar, ...)...

1 answer below »
CIT 112 Hands-on Application Activity
Week 10
1.    Chapter 27 Flow Control: Branching with if
1.1    Create a BASH script called script1.sh which takes in the name of a month (e.g. Jan, Feb, Mar, ...) and a day (e.g. 1, 2, 3, ...) as command arguments. Display whether the month is an odd (e.g. Jan, Mar, ...) or even (e.g. Feb, Apr, ...) month as well as whether the day is an odd or even day. Your input and output should look similar to the one below:
okuda@okuda:~/Day10$ . ./script1.sh Jan 1
Jan is an odd month
1 is an odd day
okuda@okuda:~/Day10$ . ./script1.sh Feb 2
Feb is an even month
2 is an even day
okuda@okuda:~/Day10$ . ./script1.sh May 4
May is an odd month
4 is an even day
1.2    Run the script and paste the output
1.3    Paste the content of the script
2.    Chapter 28 Reading Keyboard Input
2.1    Create a BASH script called script2.sh which takes in a directory name and a file name as command arguments. The script consists of two logical parts. Part 1) If the specified directory does NOT exist, prompt the user if the directory should be created. If "No", end the script. If "Yes", create the specified directory. Part 2) If the specified directory already exists, verify that the specified file exists in the specified directory. If the file does not exist, prompt the user if the file should be created under the specified directory. If "No", print the long listing of the files in the specified directory and end the script. If "Yes", create the file under the specified directory, print the long listing of the files in the specified directory, and end the script.
Your script output should look similar to the one below:
okuda@okuda:~/Day10$ . ./script2.sh DirA fileA
DirA directory does not exist. Do you want to create it (Y/N)?n
okuda@okuda:~/Day10$ . ./script2.sh DirA fileA
DirA directory does not exist. Do you want to create it (Y/N)?y
Creating DirA directory.
fileA file does not exist in DirA directory. Do you want to create it (Y/N)?n
Here is the list of files in DirA directory:
total 0
okuda@okuda:~/Day10$ . ./script2.sh DirA fileA
DirA directory exists.
fileA file does not exist in DirA directory. Do you want to create it (Y/N)?y
Creating fileA file in DirA directory.
Here is the list of files in DirA directory:
total 0
-rw-rw-r-- 1 okuda okuda 0 Apr 28 15:06 fileA
okuda@okuda:~/Day10$ . ./script2.sh DirA fileB
DirA directory exists.
fileB file does not exist in DirA directory. Do you want to create it (Y/N)?y
Creating fileB file in DirA directory.
Here is the list of files in DirA directory:
total 0
-rw-rw-r-- 1 okuda okuda 0 Apr 28 15:06 fileA
-rw-rw-r-- 1 okuda okuda 0 Apr 28 15:06 fileB
okuda@okuda:~/Day10$
2.2    Run the script and paste the output
2.3    Paste the content of the script
3.    Chapter 29 Flow Control: Looping with while/until
3.1    Create a BASH script called script3.sh which takes in a file name as a command argument. The script consists of 6 logical parts.
Part 1) Print the menu options as shown below and wait for the user response.
1. Display the Memory usage
2. Display the Disk usage
3. Print the content of the specified file
4. Exit
Part 2) If option 1 is selected, execute "free -h" command.
Part 3) If option 2 is selected, execute "df -h" command.
Part 4) If option 3 is selected, print the content of the file as specified in the command argument. Use "while read ... < filename" command, instead of "cat" command.
Part 5) if option 4 is selected, end the script.
Part 6) The whole script should be in a while true loop.
Your script output should look similar to the one below:
okuda@okuda:~/Day10$ . ./script3.sh ~/.vimrc
1. Display the disk usage
2. Display the memory usage
3. Print the content of /home/okuda/.vimrc file
4. Exit
Choose your option [1-4]:1
XXXXXXXXXXtotal XXXXXXXXXXused XXXXXXXXXXfree shared buff/cache available
Mem: XXXXXXXXXX8Gi 630Mi XXXXXXXXXX8Gi XXXXXXXXXX0Mi XXXXXXXXXX4Gi XXXXXXXXXX0Gi
Swap: XXXXXXXXXX1Gi XXXXXXXXXX0B XXXXXXXXXX1Gi
1. Display the disk usage
2. Display the memory usage
3. Print the content of /home/okuda/.vimrc file
4. Exit
Choose your option [1-4]:2
Filesystem Size Used Avail Use% Mounted on
udev XXXXXXXXXX9G XXXXXXXXXX9G 0% /dev
tmpfs XXXXXXXXXX394M 1.4M 393M 1%
un
dev/sda XXXXXXXXXX24G 6.5G 17G 29%
tmpfs XXXXXXXXXX0G XXXXXXXXXX0G 0% /dev/shm
tmpfs XXXXXXXXXX0M 4.0K 5.0M 1%
un/lock
tmpfs XXXXXXXXXX0G XXXXXXXXXX0G 0% /sys/fs/cgroup
dev/loop XXXXXXXXXX55M 55M XXXXXXXXXX% /snap/core18/1880
dev/loop2 219M 219M XXXXXXXXXX% /snap/gnome XXXXXXXXXX/66
dev/loop XXXXXXXXXX52M 52M XXXXXXXXXX% /snap/snap-store/518
dev/loop XXXXXXXXXX66M 66M XXXXXXXXXX% /snap/gtk-common-themes/1515
dev/loop XXXXXXXXXX65M 65M XXXXXXXXXX% /snap/gtk-common-themes/1514
dev/loop XXXXXXXXXX56M 56M XXXXXXXXXX% /snap/core18/1997
dev/loop6 256M 256M XXXXXXXXXX% /snap/gnome XXXXXXXXXX/36
dev/loop XXXXXXXXXX33M 33M XXXXXXXXXX% /snap/snapd/11588
dev/loop XXXXXXXXXX50M 50M XXXXXXXXXX% /snap/snap-store/467
dev/loop XXXXXXXXXX30M 30M XXXXXXXXXX% /snap/snapd/8542
dev/sda XXXXXXXXXX511M 4.0K 511M 1%
oot/efi
tmpfs XXXXXXXXXX394M 20K 394M 1%
un/use
1000
dev/sr XXXXXXXXXX59M 59M XXXXXXXXXX% /media/okuda/VBox_GAs_6.1.18
1. Display the disk usage
2. Display the memory usage
3. Print the content of /home/okuda/.vimrc file
4. Exit
Choose your option [1-4]:3
syntax on
set tabstop=4
set softtabstop=4
set expandta
set incsearch
1. Display the disk usage
2. Display the memory usage
3. Print the content of /home/okuda/.vimrc file
4. Exit
Choose your option [1-4]:4
Bye!
okuda@okuda:~/Day10$
3.2    Run the script and paste the output
3.3    Paste the content of the script
Answered 1 days After Mar 11, 2023

Solution

Sumit Kumar answered on Mar 12 2023
31 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here