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

An audit flagged world-writable files. Write a script that finds the regular files under /var, excluding symlinks and pseudo-filesystems, records their current permissions, and tightens them. How do you make the change reviewable and reversible?

HardTechnical
33 practiced

A production shell script fails only under heavy load. How would you reproduce it, trace it and fix the race or resource-starvation cause?

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.

HardTechnical
18 practiced

Write a backup script that takes incremental snapshots of a data directory, keeps daily, weekly and monthly generations, verifies each backup and cleans up on failure. What would make you distrust its first successful run?

MediumTechnical
36 practiced

How do arrays work in Bash, and where does POSIX sh differ? Write a script that stores a list of filenames given as arguments (some containing spaces) and prints each as 'index: name'.

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.