Basic Shell Scripting
Your name here (please print):
Your student ID number here:
- (3 points) Understand what the command expr does. Then
write a bash script called interactive-product to
read in two numbers, one at a time, and then print their
This script should work as follows:
[user@host name]$ ./interactive-product
Please enter the first number:
Please enter the second number:
The product is 21.
Write your script below.
echo "Please enter the first number:"
echo "Please enter the second number:"
echo "The product is" `expr $first \* $second`
- (3 points) Make three files in your home directory:
John.1, John.2 and John.3. Use "vim" to put
the name John Donn in the first one, John Smith in the second and Mary
Ann in the third. Now write a bash script that searches for
"John" in files John.k, where k goes from 1 to 5.
Write it below.
for i in `seq 1 5`
grep "John" John.$i
- (4 points) Modify the last bash script from your lecture to print
the output line in bold white font on green background. You will find
the rainbow.sh useful. Write the appropriate
echo command below.
echo -en "\033[1;37;42m"