Skip to main content

Command Palette

Search for a command to run...

Day 38: Introduction to Scripting

Learn the Basics of Scripting and Bash

Published
β€’2 min read
Day 38: Introduction to Scripting

Today I began exploring the foundational skill every DevOps engineer must know β€” scripting. I focused on Bash scripting, the most widely used shell scripting language in Linux environments.


🧠 What is Scripting?

Scripting is writing a sequence of commands to automate tasks. In DevOps, scripts are used for:

  • Automation

  • Configuration

  • Monitoring

  • Provisioning

  • CI/CD workflows


🐚 What is Bash?

Bash (Bourne Again SHell) is a Unix shell and command language. It's the default shell on many Linux distros and supports:

  • Command execution

  • Variables

  • Conditionals

  • Loops

  • Functions

  • File I/O


πŸ›  Today’s Practice:

βœ… Basic Script Structure

#!/bin/bash
echo "Hello, DevOps World!"

βœ… Variables & User Input

read -p "Enter your name: " name
echo "Welcome, $name"

βœ… If Conditions

if [ "$name" == "admin" ]; then
    echo "Access granted"
else
    echo "Access denied"
fi

βœ… Loops

for i in {1..5}; do
    echo "Iteration $i"
done

βœ… Functions

greet() {
    echo "Hello from a function"
}
greet

πŸ” Why Bash Scripting in DevOps?

  • Automates server provisioning

  • Supports CI/CD pipelines

  • Useful in Docker, Ansible, Kubernetes

  • Great for cron jobs and backups


πŸ“š What I’ll Explore Next:

  • More in variables System variables

  • Shell script best practices

  • Commad line arguments

DevOps overview as a beginner

Part 38 of 50

Sharing my journey of learning DevOps as a beginner β€” covering essential tools, cloud setup, CI/CD, Docker, monitoring, and more, step by step with practical examples.

Up next

Day 39: Bash Scripting Basics: Learn Variables and Command-Line Arguments

Bash Scripting for Beginners: How to Use Variables and Command-Line Arguments