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.

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?

MediumTechnical
23 practiced

A script with #!/bin/sh works on your laptop but fails inside an Alpine container. What Bash-specific features probably crept in, how do you find them, and how do you decide between rewriting for POSIX sh and just requiring Bash?

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'.

MediumTechnical
24 practiced

You must find the last N ERROR lines across 10,000 compressed log files spread over several servers. Describe a brute-force approach and a faster one with concrete shell commands, and reason about their cost.

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?

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.