Linux Bash Arithmetic Expressions Question:
Download Questions PDF

After running this program, if you enter 1000, then what will be the output of the program?
#!/bin/bash
echo "Please enter a number"
read a
if [ $a -lt 100 ]; then
echo "It is less than 100";
elif [ $a -lt 1000 ]; then
echo "It is less than 1000"
else
echo "It is greater than 1000"
fi
exit 0
a) It is greater than 1000
b) It is less then 1000
c) It is equal to 1000
d) none of then mentioned

Answer:

a) It is greater than 1000

Download Linux Bash Arithmetic Expressions Interview Questions And Answers PDF

Previous QuestionNext Question
Which command runs the shell built-in command 'command' with the given argument?
a) builtin
b) caller
c) there is no command present for this purpose
d) none of the mentioned
What is the output of this program?
#!/bin/bash
echo "Which file do you want to check"
read x
until [ -e $x ]
do
echo "The file does not exist. Do you want to create? y/n"
read a
if [ $a = y ]; then
touch $x
echo "Your file has been created successfully."
fi
done
echo "The file is present in this directory"
exit 0

a) it checks the existance of your entered file in the present working directory
b) it creates the file if file does not exists
c) program runs untill you create the file
d) all of the mentioned