Category Archives for Shell Scripting

Linux Shell Programs

Shell program to find sum of squares

# Shell program to find sum of squares of 10 numbers sum=0 i=0 while [ $i -ne 10 ] do echo "Enter Number" read num sum=`expr $sum + $num \* $num` i=`expr $i + 1` done echo Sum of squares … Continue reading

16. February 2009 by Jishnu
Categories: Shell Scripting | Tags: , | Leave a comment

Shell program to find sum of odd numbers in a series

# Shell program to find sum of odd numbers in a series of 10 numbers sum=0 i=0 while [ $i -ne 10 ] do echo "Enter Number" read num if [ `expr $num % 2` -ne 0 ] then sum=`expr … Continue reading

16. February 2009 by Jishnu
Categories: Shell Scripting | Tags: , | Leave a comment

Shell program to reverse a given number

# Shell program to reverse a given number echo "Enter Number" read num num2=0 while [ $num -ne 0 ] do num2=`expr $num % 10 + $num2 \* 10` num=`expr $num / 10` done echo $num2 Output ———— Enter Number … Continue reading

16. February 2009 by Jishnu
Categories: Shell Scripting | Tags: | Leave a comment

Sum of digits of a number

# Program to find sum of digits of a number echo “Enter Number” read num sum=0 while [ $num -ne 0 ] do sum=`expr $sum + $num % 10` num=`expr $num / 10` done echo Sum of Digits = $sum … Continue reading

09. February 2009 by Jishnu
Categories: Shell Scripting | Tags: | Leave a comment

Odd or Even

Shell  Program check whether a given number is odd or even echo "Enter Number" read num if [ $num -eq 0 ] then echo "Neither Even nor Odd" elif [ `expr $num % 2` -eq 0 ] then echo "Number … Continue reading

09. February 2009 by Jishnu
Categories: Shell Scripting | Tags: | Leave a comment

Newer posts →