# Day 4 - Unveiling the Power of Shell Scripting in DevOps Journey (30 Nov, 2023)

**Tasks**

* Explain in your own words and examples, what is Shell Scripting for DevOps.
    
* What is `#!/bin/bash?` can we write `#!/bin/sh` as well?
    
* Write a Shell Script which prints `I will complete #90DaysOofDevOps challenge`
    
* Write a Shell Script to take user input, input from arguments and print the variables.
    
* Write an Example of If else in Shell Scripting by comparing 2 numbers
    
    **Introduction:** Embarking on the 90 Days of DevOps challenge has been an exhilarating journey, and today's task takes us into the realm of basic Linux shell scripting. As DevOps engineers, understanding the kernel, the shell, and the art of scripting is fundamental to optimizing system operations and processes.
    
    **Demystifying the Kernel and Shell:** At the heart of every operating system lies the kernel, a program with omnipotent control over the system. Complementing the kernel is the shell, a user interface that translates human-readable commands into instructions the kernel comprehends. The shell, initiated when users log in or start a terminal, acts as a command language interpreter.
    
    **1:-Linux Shell Scripting for DevOps:** Shell scripting in the context of DevOps is a powerful tool for automating repetitive tasks, streamlining processes, and ensuring efficient management of system resources. DevOps engineers leverage shell scripts to orchestrate workflows, handle configurations, and facilitate seamless integration between development and operations.
    
    **2:-Understanding #!/bin/bash:** The shebang `#!/bin/bash` at the beginning of a shell script informs the system that the script should be interpreted using the Bash shell. Alternatively, `#!/bin/sh` could be used, but it may invoke a simpler shell interpreter. Choosing Bash provides access to a richer set of features and capabilities.
    
    **3:-Shell Script for #90DaysOfDevOps:** Let's dive into a simple shell script that echoes a commitment to completing the #90DaysOfDevOps challenge:
    
    ```plaintext
    #!/bin/bash
    
    echo "I will complete #90DaysOfDevOps challenge"
    ```
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1701344241016/00dba752-b0c2-49a5-ac23-9ca7b377643e.png align="left")
    
* This concise script encapsulates the determination to succeed in the DevOps journey.
    
    **4:-User Input and Variables in Shell Scripting:** Shell scripts can interact with users by accepting input. Here's an example:
    
    ```plaintext
    #!/bin/bash
    
    echo "Enter your name:"
    read username
    echo "Hello, $username! Welcome to the DevOps world."
    ```
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1701344255159/0a902c27-f300-44f2-9ed9-a44fa46f37b8.png align="left")
    
* This script prompts the user for their name, stores it in the variable `username`, and then greets them.
    
    **5:-If-Else Statements in Shell Scripting:** Conditional statements are vital in scripting. Consider the following example:
    
    ```plaintext
    #!/bin/bash
    
    echo "Enter two numbers:"
    read num1
    read num2
    
    if [ $num1 -eq $num2 ]; then
      echo "The numbers are equal."
    else
      echo "The numbers are not equal."
    fi
    ```
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1701344268543/10931a2b-9ffb-4fbf-9308-12909dd6ba1a.png align="left")
    
* This script compares two user-input numbers and prints a corresponding message.
