DEV Community

Kanav Gathe
Kanav Gathe

Posted on • Edited 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!

Billboard image

Monitor more than uptime.

With Checkly, you can use Playwright tests and Javascript to monitor end-to-end scenarios in your NextJS, Astro, Remix, or other application.

Get started now!

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay