Linux Bash Arithmetic Expressions Interview Questions And Answers

Download Linux Bash Arithmetic Expressions Interview Questions and Answers PDF

Optimize your Linux Bash Arithmetic Expressions interview preparation with our curated set of 50 questions. These questions are specifically selected to challenge and enhance your knowledge in Linux Bash Arithmetic Expressions. Perfect for all proficiency levels, they are key to your interview success. Secure the free PDF to access all 50 questions and guarantee your preparation for your Linux Bash Arithmetic Expressions interview. This guide is crucial for enhancing your readiness and self-assurance.

50 Linux Bash Arithmetic Expressions Questions and Answers:

Linux Bash Arithmetic Expressions Job Interview Questions Table of Contents:

Linux Bash Arithmetic Expressions Job Interview Questions and Answers
Linux Bash Arithmetic Expressions Job Interview Questions and Answers

1 :: Which built-in command performs integer arithmetic in bash shell?
a) let
b) get
c) set
d) none of the mentioned

a) let
Read More

2 :: Which expression use the value of the enclosed arithmetic expression?
a) $(())
b) $()
c) ${}
d) $[]

a) $(())
Read More

3 :: If a and b are 2 variables then the meaning of a<<=b is:
a) b = a << b
b) a = a << b
c) b = b << a
d) a = a << b

b) a = a << b
Read More

4 :: Which one of the following is bit-wise 'exclusive or' operator?
a) ^=
b) |=
c) !=
d) none of the mentioned

a) ^=
Read More

5 :: Which one of the following is not a valid operator in bash shell?
a) ||
b) ~
c) =<<
d) -=

c) =<<
Read More

6 :: What is the output of this program?
If:
1) #!/bin/bash
2) a=2
3) b=4
4) let c=a**b
5) echo $c
6) exit 0

Options:
a) 8
b) 16
c) 32
d) none of the mentioned

b) 16

Explanation:
'**' is the exponentation operator in bash shell.
Output:
root@ubuntu:/home/google#./test.sh
16
root@ubuntu:/home/google#
Read More

7 :: What is the output of this program?
#!/bin/bash
a=10; b=20
c=$((++a))
let a=c+a
echo $a
exit 0
a) 21
b) 22
c) program will generate an error message
d) none of the above

b) 22
Read More

8 :: What is the output of this program?
#!/bin/bash
a=10
b=$(( $a<0?10:$a<100 ))
echo $b
exit 0
a) 10
b) 20
c) 1
d) 0

c) 1
Firstly the '$a<0' condition has been checked. Because it is false hence the right hand side condition of the colon (:) has been checked and this is true so program output is 1.
Read More

9 :: What is the output of this program?
#!/bin/bash
a=10
b=$(( $a<0&&$a<100 ))
echo $b
exit 0
a) 10
b) 0
c) 1

b) 0
The condition '$a<0' is false so logical and operator provides the output 0.
Read More

10 :: What is the output of this program?
#!/bin/bash
a=1; b=2; c=3
d=$(( ++a**b*c++ + a ))
echo $d
exit 0

a) 14
b) 12
c) program will generate an error message
d) none of the mentioned

a) 14
The operators in decreasing order of precedence are ++, **, *, +.
Read More

11 :: Which command sets up shorthand for command or command line?
a) set
b) alias
c) new
d) echo

b) alias
Read More

12 :: What is the function of bind command in bash shell?
a) defining new macros
b) defining new key bindings for existing commands
c) dumping the installed key bindings
d) all of the mentioned

d) all of the mentioned
Read More

13 :: The command 'compgen -c' shows:
a) all variable names
b) all system wide aliases
c) full list of all commands
d) none of the mentioned

c) full list of all commands
Read More

14 :: Which statement resumes the next iteration of a for, while, select, or until loop?
a) continue
b) break
c) complete
d) command

a) continue
Read More

15 :: Which command prints the directory stack?
a) cd
b) dirs
c) popd
d) pushd

b) dirs
Read More

16 :: The command 'disown -r':
a) removes all jobs
b) removes all running jobs
c) marks jobs to not receive SIGNUP when bash exits
d) marks all jobs

b) removes all running jobs
Read More

17 :: The command 'enable -n ':
a) enables the specified built-in command
b) disables the specified built-in command
c) print the status of the command
d) none of the mentioned

b) disables the specified built-in command
Read More

18 :: Which command can create environment variable?
a) export
b) set
c) read
d) none of the mentioned

a) export
Read More

19 :: Which command concatenate the specified argument into a single command, then execute the command?
a) fc
b) eval
c) exec
d) getopts

b) eval
Read More

20 :: The command 'hash':
a) manages a internal hash table
b) find and remember the full path name of the specified command
c) displays used command names and the number of hits
d) all of the mentioned

d) all of the mentioned
Read More

21 :: 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

a) builtin
Read More

22 :: 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

a) It is greater than 1000
Read More

23 :: 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

d) all of the mentioned
Read More

24 :: How can you come out of the loop in this program?
#!/bin/bash
read x
while [ $x != "hello" ]
do
echo "Try to come out of the loop"
read x
done
echo "Welcome"
exit 0
a) by entering "hello"
b) by entering anything except "hello"
c) it is not possible
d) none of the mentioned

a) by entering "hello"
Read More

25 :: What is the output of this program?
#!/bin/bash
for i in 2 3 7
do
echo "ggl"
done
exit 0
a) 'ggl' will print 3 times
b) nothing will print
c) program will generate an error message
d) none of the mentioned

a) 'ggl' will print 3 times
Read More