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.

MediumTechnical
21 practiced

Your script works on the Linux CI image but fails on a colleague's Mac. Which everyday utilities behave differently between GNU/Linux and BSD/macOS, and how do you detect and handle the differences, or avoid them?

MediumTechnical
32 practiced

A script should create system accounts from a CSV of users, idempotently: skip users that already exist, create home directories with correct permissions, and handle initial credentials safely. How would you write it, and what are the risks of running it as root?

HardTechnical
22 practiced

Users can pass a filename to your script. Write the part that accepts it and guarantees it cannot escape a base directory, including when symlinks are involved.

HardTechnical
17 practiced

You inherit a 2,000 to 10,000 line Bash script that runs in production, with no tests and little documentation. How do you refactor it for readability and reliability while keeping regression risk low?

EasyTechnical
23 practiced

Write a small script that takes one argument, validates it, and reports whether that file exists and is readable, writable and executable, plus its size. Return exit codes a caller can rely on, and print usage on bad input.

Unlock Full Question Bank

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

Sign in to Continue

Join thousands of developers preparing for their dream job.