Interviewers test practical shell knowledge: exit codes, quoting, pipelines, and safe scripting— not obscure trivia.
Top topics
- Exit codes,
$?,set -euo pipefail - Quoting: single vs double,
"$@" - Redirection and pipes,
2>&1 find,grep,xargs -0- Environment variables and export
Sample tasks
# Count lines in all .java files under src
find src -name "*.java" -print0 | xargs -0 wc -l
# Most common IP in access.log
awk '{print $1}' access.log | sort | uniq -c | sort -nr | headExplain each stage aloud in interviews—clarity beats speed.
Compare stacks
Relate answers to Python for logic-heavy tasks and Git for hooks/CI—Bash is the glue layer.
Important interview questions and answers
- Q: What does set -o pipefail do?
A: Pipeline fails if any command fails—not only the last. - Q: $@ quoted?
A: Use "$@" to preserve separate arguments when forwarding.
Self-check
- How do you count lines in many files safely?
- What does awk print $1 do in the log example?
Tip: Explain pipelines step-by-step—interviewers care about safety (quoting, pipefail) not memorizing man pages.
Interview prep
- pipefail interview?
Pipeline should fail if any stage fails.
- Quoted $@?
Preserves separate arguments when forwarding.