Scripting

28 articles
Interview Preparation Advanced

Bash Projects

Project 1: Server Health Checker Combines: functions, conditions, exit codes, file handling. #!/usr/bin/env bash set -euo pipefail …

Jan 20, 2026 Read more
Interview Preparation Advanced

Bash Security

Command Injection: The #1 Bash Security Risk # DANGEROUS: user input concatenated directly into a command read -p "Enter filename: " …

Jan 20, 2026 Read more
Interview Preparation Advanced

Production-Grade Bash

The Standard Production Script Header #!/usr/bin/env bash set -euo pipefail IFS=$'\n\t' # safer default word-splitting (newline/tab …

Jan 20, 2026 Read more
Interview Preparation Advanced

Bash + Kubernetes

kubectl Output Formats for Scripting kubectl get pods -o json # full JSON, parse with jq kubectl get pods -o …

Jan 20, 2026 Read more
Interview Preparation Advanced

Bash + Docker

Writing a Proper Docker Entrypoint Script #!/usr/bin/env bash set -euo pipefail # Wait for a dependency before starting the main process …

Jan 20, 2026 Read more
Interview Preparation Advanced

Bash + AWS CLI

Prerequisites: CLI Configured, jq Installed aws sts get-caller-identity # confirm which account/role your credentials belong to aws …

Jan 20, 2026 Read more
Interview Preparation Advanced

Log Processing

Tailing and Filtering Logs Live tail -f /var/log/app.log | grep --line-buffered "ERROR" # --line-buffered keeps grep piping live, …

Jan 20, 2026 Read more
Interview Preparation Advanced

Networking Automation

Waiting for a Service to Become Available #!/usr/bin/env bash wait_for_port() { local host="$1" port="$2" …

Jan 20, 2026 Read more
Interview Preparation Advanced

Cron & Scheduling

The Crontab Format * * * * * command │ │ │ │ │ │ │ │ │ └── day of week (0-6, Sunday=0) │ │ │ └──── month (1-12) │ │ └────── day of month …

Jan 20, 2026 Read more
Interview Preparation Advanced

Signals & Trap

What Signals Are (Recap) Signals are how the OS or another process asks a running process to do something — most commonly, to stop. Scripts …

Jan 20, 2026 Read more
Interview Preparation Advanced

Processes & Background Jobs

Running a Command in the Background long_task.sh & # runs in the background, script continues immediately echo "Started with PID …

Jan 20, 2026 Read more
Interview Preparation Intermediate

Debugging

set -x: Trace Every Command as It Runs #!/usr/bin/env bash set -x # print each command (with expanded variables) before executing it …

Jan 20, 2026 Read more
Interview Preparation Advanced

Exit Codes & Error Handling

Exit Codes: The Universal Success/Failure Signal Every command returns a numeric exit status when it finishes: 0 means success, any non-zero …

Jan 20, 2026 Read more
Interview Preparation Intermediate

Text Processing

Why This Matters for Bash Scripting Bash itself has weak native string-manipulation tools for complex tasks — real scripts almost always …

Jan 20, 2026 Read more
Interview Preparation Intermediate

Redirection & Pipes

The Three Standard Streams flowchart LR STDIN["stdin (0)"] --> CMD[Command] CMD --> STDOUT["stdout (1)"] CMD --> STDERR["stderr (2)"] Every …

Jan 20, 2026 Read more
Interview Preparation Intermediate

File Handling

Checking Files Before Using Them FILE="config.yaml" if [ -f "$FILE" ]; then echo "Exists and is a regular file" fi [ …

Jan 20, 2026 Read more
Interview Preparation Intermediate

Command-Line Arguments

Positional Parameters #!/usr/bin/env bash # ./deploy.sh myapp production echo "Script name: $0" echo "First arg: $1" # myapp …

Jan 20, 2026 Read more
Interview Preparation Intermediate

Functions

Defining and Calling Functions greet() { echo "Hello, $1!" } greet "World" # "Hello, World!" # Alternative syntax …

Jan 20, 2026 Read more
Interview Preparation Intermediate

Arrays

Indexed Arrays SERVERS=("web1" "web2" "web3") SERVERS[3]="web4" # append at a specific index …

Jan 20, 2026 Read more
Interview Preparation Beginner

Loops

for Loops # Iterate over a fixed list for env in dev staging production; do echo "Deploying to $env" done # Iterate over a numeric …

Jan 20, 2026 Read more
Interview Preparation Beginner

Conditions

Basic if / elif / else ENVIRONMENT="staging" if [ "$ENVIRONMENT" = "production" ]; then echo "Deploying to …

Jan 20, 2026 Read more
Interview Preparation Beginner

Operators

Arithmetic Operators A=10 B=3 echo $((A + B)) # 13 echo $((A - B)) # 7 echo $((A * B)) # 30 echo $((A / B)) # 3 — integer division, no …

Jan 20, 2026 Read more
Interview Preparation Beginner

Strings

Concatenation FIRST="Hello" SECOND="World" GREETING="$FIRST $SECOND" # simple concatenation via adjacency …

Jan 20, 2026 Read more
Interview Preparation Beginner

User Input

Basic Input: read echo "Enter your name:" read NAME echo "Hello, $NAME" read -p "Enter your name: " NAME # prompt on …

Jan 20, 2026 Read more
Interview Preparation Beginner

Variables

Declaring & Using Variables NAME="deploy" echo $NAME # unquoted — works, but risky (see quoting below) echo "$NAME" # …

Jan 20, 2026 Read more
Interview Preparation Beginner

Bash Fundamentals

What Is Bash Scripting? Bash (Bourne Again SHell) is both an interactive shell and a scripting language. A Bash script is just a text file …

Jan 20, 2026 Read more