Scripting & Automation Questions
Part of the DevOps Roadmap
In short
Many DevOps interviews include a live task like 'find the top 5 IPs in this log' or 'clean up old backups'. They check if you write safe, readable scripts under a bit of pressure.
Live coding exercises in Bash or Python, or 'how would you automate X repetitive task?' — testing practical automation fluency from Phase 5.

Think of it like this
Setting the geyser timer
Instead of remembering to switch the geyser on every morning, you set its timer once. A good timer also switches off safely if the tank is full. Scripting questions test both parts: can you automate the task, and did you think about what happens when things go wrong?
Watch it happen
How to handle a live script task
1/5Ask about input format, file size, and what output they want. A 10 GB log changes the approach.
The big ideas
What you need to know
Know the classic tools
grep, awk, sort, uniq, cut, sed, find, xargs, jq. Most log questions are a pipeline of these.
Bash or Python
Bash for gluing commands; Python when you need data structures, APIs or real error handling. Say why you chose.
Idempotent scripts
Running the script twice should be safe. Check before creating, and don't fail if something already exists.
Readable beats clever
Clear variable names and a comment or two. The interviewer is picturing you writing scripts their team must maintain.
See it in code
Walk through the code
1#!/usr/bin/env bash2# Top 5 client IPs in an nginx access log3set -euo pipefail4 5LOG="${1:?usage: top-ips.sh <access.log>}"6 7awk '{print $1}' "$LOG" \8 | sort \9 | uniq -c \10 | sort -rn \11 | head -n 51/4Strict mode: stop on errors, unset variables and failures inside pipes.
In the default nginx log format the client IP is the first field. Mention that you'd check the format before trusting $1.
Save yourself the pain
Common mistakes
Oops
Writing a long script in silence and running it once at the end.
Do this instead
Build it step by step, running each piece and talking through the output. You catch mistakes early and show your thinking.
Oops
Writing a cleanup script that runs rm -rf on a path built from a variable without checks.
Do this instead
Check the variable isn't empty, use set -u, and offer a dry-run that prints what would be deleted.
Your mission
Three timed mini-tasks
Quick check
Why does the script sort before running uniq -c?
Go deeper
- 1Practice writing a small Bash or Python script live, talking through your approach.
- 2Review idempotency and error handling — commonly probed in automation-focused interviews.
- 3Practice explaining your automation choices, not just producing working code.
More ci/cd & automation at this stop
Stuck on this topic? Ask an Insider
Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.