Skip to main content

Command Palette

Search for a command to run...

BASH Scripting

Published
2 min read

SHELL

It is a program that can be served as an interface for an O.S. eg : C Shell, Corn Shell, Bourne Shell

## BASH (Bourne Again Shell)

Steps to create a bash shell:

Note : Extension : .sh

Step 1 : create a new empty file.sh

Step 2 : #!/bin/bash -->Shebang

Step 3 :- chmod +x file.sh

Step 4 :- ./file.sh --> Run

Step 5 :- # is used as comments

  • Adding #!/bin/bash as the first line of your script ,tells the OS to invoke the specified shell to execute the commands that follow in the script . #! is often referred to as a "hash-bang" , "she-bang" or "sha-bang" .It just defines the type of scripting we want .

Program 1: image.png

output : image.png

Operators

Integer Comparison

  1. q --> equal to
  2. e --> is not equal to
  3. t --> is greater than
  4. e --> greater than or equal to
  5. t --> less than or equal to
  6. < --> is less than
  7. <= --> is less than or equal to

if-else loop

image.png

image.png

Nested if- else loop

image.png

image.png

Note : $1 here represent the argument that we pass during executing the program

For loops

image.png

image.png

While loops

image.png

image.png

Until Loops

image.png

image.png

Password generator

image.png

image.png