Shell Scripting MCQ Test: Shell Scripting MCQs - Practice Questions
1. How do you assign the output of a command to a variable in a shell script?
2. What does the command 'grep' do in shell scripting?
3. In a shell script, how do you run a script located in the current directory?
4. How can you create a timestamp in a shell script?
5. What is the purpose of the 'cut' command in shell scripting?
6. What is the purpose of the 'readonly' command in advanced shell scripting?
7. What is the purpose of the 'trap' command in shell scripting?
8. Explain the purpose of the 'coproc' command in advanced shell scripting.
9. What is the purpose of the 'shopt' command in advanced shell scripting?
10. What is the purpose of the 'source' command in advanced shell scripting?
11. What command is used to move or rename files and directories in a shell script?
12. What does the 'tee' command do in a shell script?
13. What is the purpose of the 'declare' command with the '-a' option in advanced shell scripting?
14. How do you read input from the user in a shell script?
15. Explain how to implement logging in a shell script for debugging purposes.
16. Which command is used to copy files and directories in a shell script?
17. Explain how to implement a retry mechanism for a command in a shell script.
18. What is the purpose of the 'echo' command in a shell script?
19. How do you terminate a running process in a shell script?
20. What command is used to list the contents of a directory in a shell script?
21. How do you check if a variable is set in a shell script?
22. What is the purpose of the 'case' statement in shell scripting?
23. Explain the significance of the 'readonly' command in advanced shell scripting.
24. What command is used to display the manual for a command in a shell script?
25. Explain the purpose of the 'process substitution' feature in advanced shell scripting.
26. In a shell script, how do you check if a file exists before performing an operation?
27. What does the 'expr' command do in shell scripting?
28. Which command is used to print the last lines of a file in a shell script?
29. How do you comment out multiple lines in a shell script?
30. How can you implement error handling in a shell script for better debugging?
31. Explain how to create a daemon process in a shell script.
32. How do you use 'if-else' conditions in a shell script?
33. How do you handle concurrency in a shell script?
34. How can you perform a non-blocking read from a file descriptor in a shell script?
35. Explain how to handle signals in a shell script for graceful termination.
36. Which command is used to display the contents of a file in a shell script?
37. How can you pass command-line arguments to a shell script?
38. In a shell script, how do you check if a variable is empty?
39. What is the purpose of the 'dirname' command in shell scripting?
40. How do you iterate over a list of items in a shell script?
41. How do you dynamically generate function names in a shell script?
42. What is the purpose of the 'basename' command in shell scripting?
43. Which command is used to remove a file in a shell script?
44. What command is used to display the current working directory in a shell script?
45. How do you implement parallel processing in a shell script?
46. What is the purpose of the 'shebang' (#!) in the first line of a shell script?
47. How can you determine the number of CPU cores available in a shell script?
48. What is the purpose of the 'wait' command in advanced shell scripting?
49. How do you check the length of a string in a shell script?
50. How do you redirect the standard error stream in shell scripting?