Python & Bash Scripting Interview Questions — PART 3 | DevOps Live Coding

Опубликовано: 22 Август 2026
на канале: PrepLogic
3
3

In a scripting round they don't ask you to describe a script — they hand you a keyboard and watch you write one. This is Part 3 of the DevOps interview series: when to reach for Bash vs Python, three scripts written line by line, and the safety rails interviewers are actually watching for.

WHAT'S COVERED
• Bash vs Python — the one-sentence answer that lands, and the honest signal for switching
• Bash safety: set -euo pipefail, quoted variables, arrays and loops done right
• Python setup: virtualenvs, and argparse instead of sys.argv
• LIVE CODE 1 — back up a directory to a dated tar.gz archive
• LIVE CODE 2 — move files older than 30 days (with the os.walk trap explained)
• LIVE CODE 3 — count ERROR lines in a log, plus the streaming/memory gotcha
• OOP in automation — encapsulation, inheritance, polymorphism, and when NOT to use them
• Unattended jobs — idempotency, loud failure, correlation IDs, dry-run, lock files
• Jenkins Groovy pipelines at scale — Shared Libraries, declarative, pinned versions

CHAPTERS
0:00 Intro
0:25 1 — Which language
0:47 2 — Bash essentials
1:25 3 — Python essentials
2:08 4 — Backup script
2:46 5 — File mover
3:22 6 — Log counter
3:53 7 — OOP in automation
4:33 8 — Unattended jobs
5:42 9 — Jenkins at scale
6:14 Wrap up

Every script here is shown in its corrected form, with the reasoning narrated. A few details that decide these rounds: `set -euo pipefail` is why a failed tar doesn't print "Backup complete"; os.walk hands you a live list, so iterate a copy before you move files; iterating a file object streams it, while .read() pulls a 2 GB log into memory; and `except Exception: pass` is how an outage stays hidden for a week.

That's Linux, Networking and Scripting. Subscribe for the next part.

#python #bash #devops #scripting #interviewquestions #sre #devopsinterview