Basic Linux Shell Scripting

  • Shell scripting is used to automate tasks that may be time-consuming and is the process of creating and executing a sequence of commands in a shell environment to automate tasks or perform specific operations.

  • #!/bin/bash is known as shebang, also we can write it as #!/bin/sh.

  • #!/bin/bash
    echo "I will complete #90DaysOofDevOps challenge"
    //this will create a shell script that prints I will complete #90DaysOofDevOps challenge

  • #!/bin/bash

    read -p "Enter a value: " user_input

    arg1=$1 arg2=$2

    echo "User input: $user_input" echo "Argument 1: $arg1" echo "Argument 2: $arg2"
    //this script will read user input and prints it

  • #!/bin/bash
    read -p "Enter no1:" A
    read -p "Enter no2:" B
    if [ $A -gt $B ]; then
    echo "A is greater than B"
    else
    echo "B is greater than A"
    fi
    //this script will compare 2 numbers and prints the greatest number