Preparing for a DevOps interview that covers Bash & Shell Scripting? These questions come up again and again - here are strong, concrete answers.
Q: What is Bash & Shell Scripting and why use it?
Bash is the shell present on virtually every Linux system. With strict mode and a little discipline it is perfect for small, reliable automation, wrappers and glue between tools.
- Available everywhere - no runtime to install
- Perfect for gluing CLIs and small automation tasks
- Fast feedback loop for operational one-liners
Q: What are the best practices you follow?
- Start every script with set -Eeuo pipefail and an ERR trap
- Quote all variable expansions; prefer [[ ]] over [ ]
- Run shellcheck and shfmt in CI
Q: What mistakes have you seen?
- No set -euo pipefail, so failures are silently ignored
- Unquoted variables that break on spaces and globs
- Parsing ls output or using eval on untrusted input
Q: Show a basic configuration
A safe script skeleton with strict mode and a trap.
#!/usr/bin/env bash
set -Eeuo pipefail
trap 'echo "error on line $LINENO" >&2' ERR
main() {
local name="${1:?usage: deploy <name>}"
echo "deploying ${name}"
}
main "$@"Want senior help putting Bash & Shell Scripting to work - or a team bootcamp on it? CodeWizard runs Israel's largest DevOps community and embeds named senior engineers with a transparent hours log. Book a free consult or explore the Academy.