Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
function print(){
local name=$1
echo "The name is $name"
}
name="Tom"
echo "The name is $name : Before"
print Max
echo "The name is $name : After "
#!/bin/bash
function print(){
echo $1 $2 $3
}
quit () {
exit
}
print Hello World Again
#!/bin/bash
for (( i=0; i<=10; i++ ))
do
echo $i
done
#! /bin/bash
n=1
while [ $n -le 10 ]
do
echo "$n"
(( n++ ))
done
#! /bin/bash
vehicle=$1
case $vehicle in
"car" )
echo "Rent of $vehicle is 5 lakhs" ;;
"van" )
echo "Rent of $vehicle is 4 lakhs" ;;
* )
#! /bin/bash
num1=20
num2=5
echo $(expr $num1 + $num2 )
echo $(expr $num1 - $num2 )
echo $(expr $num1 \* $num2 )
echo $(expr $num1 / $num2 )
echo $(expr $num1 % $num2 )
#! /bin/bash
num1=20
num2=5
echo $(( num1 + num2 ))
echo $(( num1 - num2 ))
echo $(( num1 * num2 ))
echo $(( num1 / num2 ))
echo $(( num1 % num2 ))
#! /bin/bash
read count
if [ $count -gt 18 -o $count -lt 35 ]
then
echo "Valid Age"
else
echo "Age not Valid"
fi
#! /bin/bash
read count
if [ $count -gt 18 ] || [ $count -lt 30 ]
then
echo "Valid Age"
else
echo "Age not Valid"
fi
#! /bin/bash
read count
if [ $count -gt 18 -a $count -lt 35 ]
then
echo "Valid Age"
else
echo "Age not Valid"
fi