Description
1. (2 pt.) Write a shell script named “sum.sh” that reads sequence of integers on the command line. Each integer are separated by a space and prints their sum to the screen.
Use for loop.Do not use (()) in looping or any value evaluation.
For example, when you run this script with 10 sequences of integers
./sum.sh 1 2 3 4 5 6 7 8 9 10
output of the script will be
Sum of Arguments is 55.
2. (1 pt.) There are two types of libraries: static library and shared library. Briefly explain differences between static and shared library.
3. (1 pt.) Following shows students information (ID, last name, first name, age phone number) in the student.txt file. You need collect student data with string “Smith”.
Write commands with pipe and output redirection to find all student data with “Smith” in the student.txt and sort them based onage, and save in a file named “Smith.txt”.
4. (1 pt.) Briefly explain the difference between the following two commands:
ls -l | less
ls -l > less
5. (1 pt.) What are two conditions to make a shell script file executable
6. (1 pt.) Given the following variable what will be displayed for each of the following shell commands?
variable=”You are my sunshine!”
• echo variable
• echo “$variable”
• echo ‘$variable’
• echo \$variable
• echo \$$ variable
7. (1 pt.) Write a script to calculating factorial of given number by using while loop. The scriptasksan integer value and calculates factorial and display the result. Do not use (()) in looping or any value evaluation.
8. (2 pt.) Write shell script to display triangle shapes based on base length of triangle. A base value must be odd number greater than 3. Need get a size of base input from keyboard. Do not use (()) in looping or any value evaluation.