Linux Bash Arithmetic Expressions Interview Preparation Guide Download PDF
Bash Arithmetic Expressions frequently Asked Questions in various Linux Bash Arithmetic Expressions job Interviews by interviewer. The set of questions here ensures that you offer a perfect answer posed to you. So get preparation for your new job hunting
50 Linux Bash Arithmetic Expressions Questions and Answers:
Table of Contents
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
5 :: Which one of the following is not a valid operator in bash shell?
a) ||
b) ~
c) =<<
d) -=
c) =<<
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#
Explanation:
'**' is the exponentation operator in bash shell.
Output:
root@ubuntu:/home/google#./test.sh
16
root@ubuntu:/home/google#
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.
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.
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.
The condition '$a<0' is false so logical and operator provides the output 0.
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 ++, **, *, +.
The operators in decreasing order of precedence are ++, **, *, +.
11 :: Which command sets up shorthand for command or command line?
a) set
b) alias
c) new
d) echo
b) alias
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
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
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
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