Skip to main content

Command Palette

Search for a command to run...

DevOps(Day-4)

Updated
2 min read
DevOps(Day-4)
B

I like to explore the technology in DevOps area where I write blog about my learning each day on the tools that is mostly used in Industries for DevOps practices. You can go through my blogs and reach me out in LinkedIn for any suggestions.

Shell scripting in LINUX

  1. What is Shell Scripting?

    It is a set of commands written in an executable file to automate any task. The commands are converted then to machine-readable form to execute.

    Syntax:-

    #!/bin/bash

    <commands>

    The file to be created must be with extension ".sh" and provided with necessary execute permissions to the user running the script.

  2. What is `#!/bin/bash'? can we write `#!/bin/sh` as well?

    #! is called Shebang. It contains the path (/bin/bash) which uses the shell for executing the code written in the script file.

    BASH - Bourne again shell

    /bin/bash can execute the majority of scripts thus it is used widely.

    /bin/sh is an executable representing the system shell and is usually implemented as a symbolic link pointing to the executable for whichever shell is the system shell. The system shell is the default shell that the script should use.

    Basically, it points to /bin/bash but nowadays it became /bin/dash which is faster.

  3. Write a Shell Script which prints `I will complete #90DaysOofDevOps challenge`

    vim first_script.sh


    #!/bin/bash

    echo "I will complete #90DaysOofDevOps challenge"


    Chmod 777 first_script.sh

    ./first_script.sh

  4. Write a Shell Script to take user input, input from arguments and print the variables.

    #!/bin/bash

    echo "Hello I am $1"

  5. Write an Example of If else in Shell Scripting by comparing 2 numbers

    #!/bin/bash

    a=10

    b=20

    if [[ $a -gt $b ]]

    echo "a is greater than b"

    else

    echo"b is greater than a"

More from this blog

Untitled Publication

98 posts