Basic Shell Scripting For DevOps

Basic Shell Scripting For DevOps

·

2 min read

Day 4 of #90daysofDevOps with #Trainwithshubham.

What is Kernal?

Kernal is an essential part of OS. It is the core which controls everything in the system such as the CPU, memory, etc. It is the main layer between OS and Hardware.

What is Shell?

A shell is an interpreter which interprets the command written by users on terminals and covert to computer binary language. It takes a command from the user and calls OS to run. It is also a programming language with variables and conditional statements that executes a shell script.

What is Linux Shell Scripting?

The collection of commands in a file that runs on a shell to avoid repetitive work. The shell script is denoted as .sh. Shell script performs operations such as file manipulation, program execution, etc.

What is #!/bin/bash?

This is a shebang line used in a script as a first line to set bash, which is present in /bin directory.

Can we write #!/bin/sh?

There are mainly two types of Shell

  • Bourne Shell

    • Bourne shell (sh)

    • Korn Shell (ksh)

    • Bourne Again shell (bash)

    • POSIX shell (sh)

  • C Shell

    With the shebang we tell the terminal to run the script and use bash/sh to execute it. There is not much difference in both but sometimes the script works in bash and not in sh.

    So, to conclude yes we can write #!/bin/sh too.

Task

  • 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.

1. Take user input: $ nano takeinput.sh

Execute on terminal

  1. Input through argument: $ nano giveargument.sh

Execute on terminal

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

    Execute on terminal

Happy Learning!!