Shell Scripting and Automation Questions

Shell-language craft for operations work: Bash and POSIX sh scripting, pipes and redirection, quoting and word splitting, exit codes and set -euo pipefail (including failures inside pipelines), traps and cleanup, argument parsing with getopts, functions and arrays, parameter expansion, here-documents, and text processing with grep, sed, awk and jq, including streaming pipelines over very large log, CSV and JSON Lines files. Also covers writing robust, idempotent, portable scripts (locking, atomic file updates, retries with backoff, safe temp files, GNU versus BSD differences), background jobs and signals, bounded parallelism and SSH fan-out, cron-driven jobs such as log rotation, backups, atomic deploys and health-check watchdogs, secure scripting (eval injection, secrets, path traversal), and debugging, testing and linting shell with ShellCheck and bats. Boundary: general automation design and Python or Go tooling, Linux host administration tasks, observability and alerting design, security detection engineering, and generic algorithmic coding problems are covered elsewhere.

EasyTechnical
18 practiced

How do you make a Bash script clean up after itself when it exits normally, fails part-way, is interrupted with Ctrl-C, or is terminated by another process? Explain what you hook, what happens to the exit status, and what behaves differently in subshells and functions.

EasyTechnical
23 practiced

What is the difference between a shell variable and an environment variable? Explain why VAR=1 bash -c 'echo $VAR' prints nothing, how to make a value visible to child processes, and how you would set one for a single command versus every login session.

EasyTechnical
20 practiced

When would you reach for grep, sed or awk? Give a short example of each: finding lines that match an IP address, rewriting a token in a stream, and extracting and summing a column.

MediumTechnical
24 practiced

How would you collect the files found by find into a Bash array and then loop over them, even when names contain odd characters? What are the memory and portability trade-offs?

EasyTechnical
20 practiced

Schedule a nightly ETL job to run at 02:30 with cron. Provide the crontab line, explain its fields, and describe why a script that works in your terminal can fail under cron and how you would make failures visible and prevent overlapping runs.

Unlock Full Question Bank

Get access to all 47 Shell Scripting and Automation interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.