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
34 practiced

Read many gzipped JSON Lines files, extract id, timestamp and value, write one CSV with a single header, and remove duplicate ids. Show the pipeline and explain how it stays streaming.

MediumTechnical
18 practiced

A nightly script reports 'backup complete' even on nights when the archive on the remote host is empty. The core of it is: tar czf - /srv/data | ssh backup@host 'cat > /backups/data.tgz' followed by echo 'backup complete'. Explain why failures go unnoticed, fix it, and say what your fix still would not catch.

MediumTechnical
25 practiced

Given a web server access log, output the five client IPs with the most requests. Then extend it to count only ERROR lines from the last 7 days, or timeout messages from the last 24 hours, and count distinct sources.

HardTechnical
20 practiced

A script runs grep pattern "$file" | wc -l once per file over tens of thousands of files and takes forever. Why is it slow, and how would you restructure it?

EasyTechnical
20 practiced

How would you send a command's standard output to one file and its error output to another, and also pipe the output through a filter? Explain how the order of redirections matters and how you would capture only the errors in a data pipeline.

Unlock Full Question Bank

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

Sign in to Continue

Join thousands of developers preparing for their dream job.