← All interview questions

Skill Zuno · skillzunos.com · Cloud

Shell Script interview questions

Prepare for Shell Script interviews on Skill Zuno. This practice book covers Shell Script interview questions across New, Easy, Medium, Hard, and Diff levels so you can work through real interview-style problems on skillzunos.com.

Open Shell Script on Skill Zuno

Also see the Shell Script tutorial.

Shell scripting automates tasks on Linux and macOS by combining commands in Bash or another shell. DevOps engineers use it for deployments, log processing, backups, CI steps and server setup. Shell scripting interviews cover variables and quoting, conditionals and loops, exit codes and error handling, pipes and redirection, text processing with grep, sed and awk, and writing safe, portable scripts.

Sample Shell Script interview questions

What does set -euo pipefail do?

-e exits on any failing command, -u treats unset variables as errors, and pipefail makes a pipeline fail if any command in it fails, not just the last. Together they stop scripts silently continuing after errors.

Why should variables be quoted?

Unquoted variables undergo word splitting and glob expansion, so a filename with spaces becomes several arguments. Writing "$file" passes it as one argument.

What is the difference between $@ and $*?

Quoted, "$@" expands to each argument as a separate word, preserving spaces inside them. "$*" joins all arguments into one string. Use "$@" to pass arguments on.

How do you redirect both stdout and stderr to a file?

command > out.log 2>&1, or &> out.log in Bash. The order matters: 2>&1 must come after the stdout redirection.

What does trap do?

It runs a command when the script receives a signal or exits, such as trap 'rm -f "$tmp"' EXIT, which guarantees temporary files are cleaned up.

What you can practice

  • Shell Script interview questions for beginners and experienced developers
  • Level-based practice: New, Easy, Medium, Hard, and Diff
  • Cloud topics alongside Shell Script on skillzunos.com

More Cloud interview questions

All interview questions