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!

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

Image of Docusign

πŸ› οΈ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more