# Hello World Program in Bash Shell #echo "Hello World!" echo "Ashraful Islam" echo "Enter a number: " read N echo $N echo "$N" echo "You Entered : $N" #echo "Enter another number: " #read M #echo $M #echo "$M" #echo "You Entered : $M" VAR1=17 VAR2=19 VAR3=20 V=`expr $N + $VAR2` echo $V echo "Values of the Variables: " echo $VAR1 echo $VAR2 echo $VAR3 VAR4=`expr $VAR1 + $VAR2` echo "$VAR1 + $VAR2 = $VAR4" VAR4=`expr $VAR1 * $VAR2` echo "$VAR1 * $VAR2 = $VAR4" A[0]=77 A[1]=78 A[2]=79 echo $A[0] echo $A[1] echo $A[2] echo ${A[0]} echo ${A[1]} echo ${A[2]} B=(44 45 46 47 48) echo ${B[0]} echo ${B[1]} echo ${B[2]} New=`expr ${B[3]} + ${B[4]}` echo $New echo "Greater number between Variable 1 & Variable 2: " if [ $VAR1 -gt $VAR2 ] then echo "$VAR1 is greater" else echo "$VAR2 is greater" fi echo "Greater number among Variable 1 , Variable 2 & Variable 3: " if [ $VAR1 -gt $VAR2 ] then if [ $VAR1 -gt $VAR3 ] then echo "$VAR1 is greater" else echo "$VAR3 is greater" fi else if [ $VAR2 -gt $VAR3 ] then echo "$VAR2 is greater" else echo "$VAR3 is greater" fi fi echo "Smallest number among Variable 1 , Variable 2 & Variable 3 of Array B: " if [ ${B[0]} -lt ${B[1]} ] then if [ ${B[0]} -lt ${B[2]} ] then echo "${B[0]} is smallest" else echo "${B[2]} is smallest" fi else if [ ${B[1]} -lt ${B[2]} ] then echo "${B[1]} is smallest" else echo "${B[2]} is smallest" fi fi NUMBER=10 while [ $NUMBER -gt 0 ] do echo $NUMBER NUMBER=$((NUMBER-1)) done NUMBER1=10 while [ $NUMBER1 -ge 0 ] do echo $NUMBER1 NUMBER1=$((NUMBER1-1)) done i=1 NUMBER2=10 while [ $i -lt $NUMBER2 ] do echo $i i=$((i+1)) done sum=0 for((j=1;j<=$NUMBER2;j++)) { sum=$((sum+j)) } echo "Sum of the given sequence = $sum" sum_ID=0 ID=(1 9 1 1 5 1 2 1 7 3) echo "Sum of the digits of ID: " for((k=0;k<10;k++)) { sum_ID=`expr $sum_ID + ${ID[k]}` } echo $sum_ID sum_ID1=0 m=0 while [ $m -lt 10 ] do sum_ID1=`expr $sum_ID1 + ${ID[m]}` m=`expr $m + 1` done echo "Sum of the digits of ID: $sum_ID1"