Blog 14 From Basics to Pro: Functions, Logs & Loops in Shell Scripting
Functions, Colors, Logs & Loops in Shell Scripting Functions, Colors, Logs & Loops in Shell Scripting Welcome back to our shell scripting series 🚀 In the last blog, we covered variables, conditions, and datatypes. Today, let’s step into some powerful concepts: Functions, Colors, Logs, and Loops . These are the real game-changers when building scripts for automation. 1️⃣ Functions – Reuse Your Code A function is like a shortcut. Instead of repeating the same lines, wrap them in a function and call it anytime. FUNC_NAME() { # code here } FUNC_NAME # calling function 2️⃣ Passing Arguments You can pass inputs to your function. Inside the function, $1 means the first argument, $2 the second, and so on. FUNC_NAME input1 input2 FUNC_NAME() { echo "First arg: $1" echo "Second arg: $2" } 3️⃣ Why Use Functions? Follow DRY → Don’t Repeat Yourself Keep scripts clean & s...