After running this program, as you press ‘s’, what will be the output of the program? [code] #!/bin/bash echo "press 's' to print 123hoida

After running this program, as you press ‘s’, what will be the output of the program?
Code:
   #!/bin/bash
   echo "press 's' to print 123hoidap"
   read var
   if $var=s
   then
   echo "123hoidap"
   else
   echo "You did not press s"
   fi
   exit 0
A. Sanfoudry
B. You did not press s
C. Program will generate an error message
D. None of the mentioned
 
Answer: c
Explanation: The condition of if statement must be in square brackets.
Output:
root@ubuntu:/home/123hoidap#./test.sh
press ‘s’ to print 123hoidap
s
./test.sh: line 4: s=s: command not found
You did not press s
 

Tìm kiếm

Back
Top