Bash (Coding) Quiz
Bash shell scripting: the automation and glue-code language behind most Linux/Unix system administration.
This category currently has 60 questions in the SERVBG quiz bank. Below are a few sample questions: the full interactive quiz shuffles through the whole set with instant scoring.
Sample questions
What does $? expand to in Bash?
- The exit status of the last foreground command
- The PID of the current shell
- The number of arguments passed
- The PID of the last background process
- The name of the script
Which expansion gives the length of the variable var?
- ${#var}
- $(len var)
- ${var:#}
- $#var
- ${var.length}
What does ${var:-default} expand to?
- The value of var if set and non-empty, otherwise the literal "default"
- Returns 1 as exit status
- The literal "default" always
- Errors out if var is unset
- Sets var to "default" and returns it
What does ${var:=default} differ from ${var:-default} in?
- It exports var globally
- It is reserved for arrays only
- It is identical to :-
- It deletes var if unset
- It assigns "default" to var when var is unset/empty, then expands to it
What does ${var:+other} expand to?
- The length of var
- "other" when var is set and non-empty, otherwise empty
- "other" always
- "other" when var is unset
- The first word of var
Related categories
Python (Coding)
Python syntax, standard-library usage, and the language idioms that come up in day-to-day scripting and application work.
JavaScript (Coding)
Core JavaScript language behavior, async patterns, and the quirks that trip up both beginners and experienced developers.
Linux
Linux command-line usage, file permissions, process management, and the everyday admin tasks every sysadmin and developer needs.
Security
General information security concepts: threats, defenses, and the fundamentals every IT professional should know.
Hardware
Computer hardware components, how they interact, and the troubleshooting knowledge behind keeping systems running.