Bash (Coding) Quiz
Bash shell scripting, the everyday automation language of Linux and Unix 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 PID of the current shell
- The name of the script
- The PID of the last background process
- The number of arguments passed
- The exit status of the last foreground command
Which expansion gives the length of the variable var?
- ${var:#}
- $#var
- $(len var)
- ${var.length}
- ${#var}
What does ${var:-default} expand to?
- The literal "default" always
- Returns 1 as exit status
- Sets var to "default" and returns it
- Errors out if var is unset
- The value of var if set and non-empty, otherwise the literal "default"
What does ${var:=default} differ from ${var:-default} in?
- It deletes var if unset
- It exports var globally
- It is identical to :-
- It assigns "default" to var when var is unset/empty, then expands to it
- It is reserved for arrays only
What does ${var:+other} expand to?
- "other" always
- The length of var
- The first word of var
- "other" when var is unset
- "other" when var is set and non-empty, otherwise empty
Related categories
Python (Coding)
Python syntax and standard-library usage, from quick scripts to full applications.
JavaScript (Coding)
Core JavaScript behavior and async patterns, including the quirks that trip up beginners and veterans alike.
Linux
Linux command-line usage, file permissions, process management. The daily admin tasks.
Security
General information security concepts: common threats and standard defenses.
Hardware
Hardware components, how they interact, and basic troubleshooting to keep systems running.