Bash Script

 

Introduction to the Bash Shell :-


The Linux command line is provided by a program called the shell.

File extension of .sh.

ex:- example.sh

#! /usr/bin/bash

echo "Hello World"

Provide execution rights to your user:-

chmod u+x example.sh


Run the script :-

You can run the script in the following ways:

./example.sh

How to define variables

We can define a variable by using the syntax variable_name=value. To get the value of the variable, add $ before the variable.

#!/usr/bin/bash

# A simple variable example

greeting=Hello

name=Tux

echo $greeting $name

How to read user input


#!/usr/bin/bash

echo "Enter a numner"

read a

echo "Enter a numner"

read b

var=$((a+b))

echo $var

Comments

Popular posts from this blog

Static IP In Linux