Linux Questions & Answers On Bash Shell Programming - Sanfoundry
Linux Questions & Answers On Bash Shell Programming - Sanfoundry
a) The process id is $$
b) The process id is $<pid>$<pid>
c) The process id is <pid><pid>
d) The process id is $$$$
View Answer
Answer: c
Explanation: None.
2. What would be the current working directory at the end of the following command sequence?
advertisement
Driving mobility
READ MORE
sponsored by: Mitsubishi Electric
https://www.sanfoundry.com/linux-shell-programming-mcq-1/ 1/9
1/31/24, 4:13 AM Linux Questions & Answers on Bash Shell Programming - Sanfoundry
$ pwd
/home/user1/proj
$ cd src
$ cd generic
$ cd .
$ pwd
a) /home/user1/proj
b) /home/user1/proj/src
c) /home/user1
d) /home/user1/proj/src/generic
View Answer
3. How do you print the lines between 5 and 10, both inclusive
a) cat filename | head | tail -6
b) cat filename | head | tail -5
c) cat filename | tail +5 | head
d) cat filename | tail -5 | head -10
View Answer
Answer: a
Explanation: None.
Answer: b
Explanation: None.
advertisement
https://www.sanfoundry.com/linux-shell-programming-mcq-1/ 2/9
1/31/24, 4:13 AM Linux Questions & Answers on Bash Shell Programming - Sanfoundry
Answer: d
Explanation: None.
advertisement
os=Unix
echo 1.$os 2."$os" 3.'$os' 4.$os
Answer: b
Explanation: None.
os = Unix
[$osName = UnixName] && exit 2
[${os}Name = UnixName] && exit 3
a) 0
b) 1
c) 2
d) 3
View Answer
Answer: d
Explanation: None.
x = 3; y = 5; z = 10;
if [( $x -eq 3 ) -a ( $y -eq 5 -o $z -eq 10 )]
then
echo $x
else
echo $y
fi
a) 1
b) 3
c) 5
d) Error
View Answer
Answer: b
Explanation: None.
https://www.sanfoundry.com/linux-shell-programming-mcq-1/ 4/9
1/31/24, 4:13 AM Linux Questions & Answers on Bash Shell Programming - Sanfoundry
[ -n $HOME ]
echo $?
[ -z $HOME ]
echo $?
a) 0
1
b) 1
0
c) 0
0
d) 1
1
View Answer
Answer: a
Explanation: None.
b =
[ -n $b ]
echo $?
[ -z $b ]
echo $?
a) 1
1
b) 2
2
c) 0
0
d) 0
1
View Answer
Answer: c
Explanation: None.
d) 2
View Answer
Answer: c
Explanation: None.
12. The statement z = ‘expr 5 / 2’ would store which of the following values in z?
a) 0
b) 1
c) 2
d) 2.5
View Answer
Answer: c
Explanation: None.
Sanfoundry Global Education & Learning Series – Linux Administration & Programming.
Here’s the list of Best Books in Linux Commands & Shell Programming.
Here’s the list of Best Books in Linux Kernel, Device-Drivers & System Programming.
To practice all questions on Linux Administration & Programming, here is complete set of 1000+
Multiple Choice Questions and Answers on Linux.
« Prev - Linux Questions & Answers – User » Next - Linux Questions & Answers – Shell
Account Management Environment – 1
Related Posts:
advertisement
https://www.sanfoundry.com/linux-shell-programming-mcq-1/ 6/9
1/31/24, 4:13 AM Linux Questions & Answers on Bash Shell Programming - Sanfoundry
Recommended Articles:
1. Linux Shell Programming Questions and Answers – Functions
2. Linux Shell Programming Questions and Answers – Variables
3. Linux Questions & Answers – Shell Environment – 2
4. Linux Bash Shell Questions & Answers – Built-in Commands – 3
5. Linux Bash Shell Questions & Answers – Arithmetic Expressions
6. Linux Questions & Answers – File Permissions – 1
7. Linux Questions & Answers – Search Pattern
8. C++ Programming Questions and Answers – Complex Library – 2
9. Linux Bash Shell Questions and Answers – Command History and Job Control
10. Linux Questions & Answers – Shell Environment – 1
advertisement
Additional Resources:
https://www.sanfoundry.com/linux-shell-programming-mcq-1/ 7/9
1/31/24, 4:13 AM Linux Questions & Answers on Bash Shell Programming - Sanfoundry
Popular Pages:
C Programming Interview Questions
Object Oriented Programming MCQ Questions
C Programming Examples
Java Programming Examples
Linux Commands with Examples
Name
Subscribe
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is
Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on
development of Linux Kernel, SAN Technologies, Advanced C, Data
Structures & Alogrithms. Stay connected with him at LinkedIn.
https://www.sanfoundry.com/linux-shell-programming-mcq-1/ 8/9
1/31/24, 4:13 AM Linux Questions & Answers on Bash Shell Programming - Sanfoundry
https://www.sanfoundry.com/linux-shell-programming-mcq-1/ 9/9