
Shell Programming 2
Authored by vamsi j
Computers
University
Used 1+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
15 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
#!/bin/bash
name="Alice"
echo "Hello, $name!"
What will be the output of the above script?
a) Hello, World!
Hello, Alice!
Hello, $name!
Syntax Error
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
#!/bin/bash
a=10
b=5
sum=$((a + b))
echo "The sum of $a and $b is $sum"
What will be the output of the above script?
a) The sum of 10 and 5 is 105
The sum of 10 and 5 is 15
The sum of 10 and 5 is 10+5
Syntax Error
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
#!/bin/bash
number=7
if [ $number -gt 5 ]; then
echo "Number is greater than 5"
else
echo "Number is less than or equal to 5"
fi
Number is less than or equal to 5
Number is greater than 5
Syntax Error
No output
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
#!/bin/bash
for i in 1 2 3
do
echo "Iteration $i"
done
a) Iteration 0, Iteration 1, Iteration 2
Iteration 1, Iteration 2, Iteration 3
Iteration 1, Iteration 1, Iteration 1
No output
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
#!/bin/bash
current_date=$(date)
echo "Today's date is: $current_date"
What will be the output of the above script?
Today's date is: <current date and time>
Today's date is: $(date)
Today's date is: current_date
Syntax Error
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
#!/bin/bash
counter=1
while [ $counter -le 3 ]
do
echo "Counter: $counter"
counter=$((counter + 1))
done
What will be the output of the above script?
Counter: 1, Counter: 1, Counter: 1
Counter: 1, Counter: 2, Counter: 3
Counter: 3, Counter: 2, Counter: 1
No output
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
#!/bin/bash
greet() {
echo "Hello, $1!"
}
greet "World"
What will be the output of the above script?
Hello, Alice!
Hello, $1!
Hello, World!
Syntax Error
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?