Lab03_CT104H
Lab03_CT104H
Study from the files: Linux Shell Scripting Tutorial, and Shell Script (Chapter 2, 3), Advanced Bash-Scripting
Guide (Chapter 13)
CT104H – Operating System
Question 1: Write a shell script that prints the message “Hello ! This is CT104” to the screen.
Question 2: Modify the shell script from Question 1 to include a variable. The variable will hold the content
of the message.
Question 3: Write a shell script that prints the following information to the screen
Today is <current date>
Hello <username>
Your current working directory is <current directory>
Your home directory is <home directory>
Please press any key to finish <wating to receive a key from user>
********* Thank you
Question 4: Write a shell script that receives 2 numbers from a user, and calculates the following values
Please input the first number: x = x
Please input the second number: y = y
(x-y) = <x-y>
(x+y) = <x+y>
(x*y) = <x*y>
(x/y) = <x/y>
(x%y) = <x%y>
x2= x2
x! = x!
Question 5: Write a shell script that allows a user to input a name of a directory, and creates this directory for
the user. If the directory is created, please print the message “The name_of_directory is created successfully”
to the screen; otherwise, print the message “Can not create the name_of_directory” to the screen.
Question 6: Write a script to print the following symbols to the screen
*
**
***
****
*****
******
*******
********
*********
**********
CT104H – Operating System
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
Question 7: Write a shell script to solve the equation ax+b=0 where the coefficients a and b entered from the
keyboard
Question 8: Write a shell script to print a multiplication table of a number entered by the user to the screen.
After printing out the multiplication table, the program will ask the user to type “1” if the user wants to continue
the process; otherwise, the process of printing the multiplication table will end.
Question 9: Write a shell script that allows users to input an int number and returns the digit number of that
number. For example, 10 → returns “two-digit number”; 100 → returns “three-digit number”.
----------------------END----------------------