DEV Community

Kanav Gathe
Kanav Gathe

Posted on

Day 4/90: Shell Scripting Basics for DevOps 📜 #90DaysOfDevOps

Day 4: Shell Scripting Basics for DevOps Engineers 🚀

Hello DevOps enthusiasts! 👋 Welcome to Day 4 of the #90DaysOfDevOps challenge. Today, we're diving into shell scripting basics, a crucial skill for automation in DevOps.

Understanding the Basics 📝

What is Kernel?

The kernel is the core component of an operating system that manages:

  • System resources
  • Hardware communication
  • Process management
  • Memory management

What is Shell?

Shell is an interface between users and the kernel, allowing us to:

  • Execute commands
  • Automate tasks
  • Manage system resources
  • Process user inputs

Task Solutions 💻

1. Print Challenge Message

#!/bin/bash
echo "I will complete #90DaysOfDevOps challenge"
Enter fullscreen mode Exit fullscreen mode

2. Take User Input and Arguments

#!/bin/bash
# Read user input
read -p "Enter your name: " username
echo "Hello, $username!"

# Display script arguments
echo "Script arguments: $@"
Enter fullscreen mode Exit fullscreen mode

3. Compare Two Numbers

#!/bin/bash
read -p "Enter first number: " num1
read -p "Enter second number: " num2

if [ $num1 -gt $num2 ]; then
    echo "$num1 is greater than $num2"
elif [ $num1 -lt $num2 ]; then
    echo "$num1 is less than $num2"
else
    echo "Both numbers are equal"
fi
Enter fullscreen mode Exit fullscreen mode

Key Components Used 🔧

  1. Shebang (#!/bin/bash)

    • Tells system to use bash interpreter
  2. Echo Command

    • Displays text/variables
  3. Read Command

    • Captures user input
  4. If-Else Statement

    • Controls program flow
    • Compares values
  5. Variables

    • Store and manipulate data

Key Takeaways 💡

  • Shell scripts automate repetitive tasks
  • Basic constructs enable powerful automation
  • User input makes scripts interactive
  • Proper script structure is important

Bash #DevOps #Automation #Linux #90DaysOfDevOps


This is Day 4 of my #90DaysOfDevOps journey. Keep learning and automating!

Top comments (0)