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
Subscribe to my newsletter
Read articles from Shaharyar Shakir directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
