Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 8

Shell Scripting

Omkar Udase (5715)


IF Code
#!/bin/bash
number=101
if [ $number -gt 100 ]
then
echo “Hey that\'s a large number.”
fi

2
IF Code
#! /bin/sh

a=99
b=45

if [ $a -lt $b ]
then
echo "a is less than b"
else
echo "a is greater than b"
fi

3
IF Else Code
#!/bin/bash
m=1
n=2

if [ $n -eq $m ]
then
echo "Both variables are the same"
else
echo "Both variables are different"
fi

4
IF Else Code
#!/bin/bash
a=2
b=7
if [ $a -ge $b ]
then
echo "The variable 'a' is greater than the variable 'b'."
else
echo "The variable 'b' is greater than the variable 'a'."
fi

5
IF Else Code
#!/bin/bash
n=10
if [ $((n%2))==0 ]
then
echo "The number is even."
else
echo "The number is odd."
fi

6
IF Else Code
#!/bin/bash
echo "Enter password"
read pass
if [ $pass="password" ]
then
echo "The password is correct."
else
echo "The password is incorrect, try again."
fi

7
8

You might also like