Question: We're going to try a few different things that will get us acclimated to Unix/Linux shell scripting... 1) Launch vi and create the following script:
We're going to try a few different things that will get us acclimated to Unix/Linux shell scripting...
1) Launch vi and create the following script: #!/bin/bash #my first script echo "expr 1 + 1" echo 'expr 1 + 1' echo `expr 1 + 1`
2) Make the script executable. Before you run the script, Q1: which statement will output the value 2?
3) Launch vi and create the following script: #!/bin/bash #my second script x=20 y=5 echo 'expr x / y'
4) There are two errors in the above script. Q2: What are they? Q3: How would you fix the script so that you get the output 4?
Examine the following script and then answer the questions: #!/bin/bash number= if [ $number = "1" ]; then echo "Number equals 1" else echo "Number does not equal 1" fi Q4: What is the exact error message you get when running this script?
Q5: How would you fix the script so that there is no error? Examine the following script and then answer the questions: #!/bin/bash echo Please enter a value: read number if [ $number = "1" ] then echo "Number equals 1" else echo "Number does not equal 1" fi Q6): What is the error you receive when running this script? How would you fix the error?
Q7) What happens if we provide the value a when prompted by the script? Why?
Q8) How would you change this script so that only integers are evaluated against 1?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
