echo "Enter the range" read r a = 0 b = 1 c = 1 echo "Fibonacci series:\n" echo "$a $b \c" while [ $c - lt $r ] do c = `expr $a + $b` if [ $c - le $r ] then echo "$c \c" fi a = $b b = $c done echo "\n"
echo "Enter the Number of Terms" read n a = 0 b = 1 count = 1 n1 = `expr $n - 2` if [ $n - eq 1 ] then echo "The Fibonacci series is:" $a elif [ $n - eq 2 ] then echo "The Fibonacci series is:" $a $b else echo "The Fibonacci series is:" echo "$a $b \c" while [ $count - le $n1 ] do c = `expr $a + $b` echo "$c \c" a = $b b = $c count = `expr $count + 1` done fi echo "\n"
echo "Enter a number" read n f = 1 if [ $n - eq 0 ] then echo "Factorial is: 1" else while [ $n - ge 1 ] do f = `expr $f \* $n` n = `expr $n - 1` done echo "Factorial is:" $f fi
echo "Enter the Value of x" read x echo "Enter the Value of y" read y r = 1 while [ $y - gt 0 ] do r = `expr $x \* $r` y = `expr $y - 1` done echo "The value of x^y is:" $r
clear echo "Enter the String:\c" read str echo "Enter the character:\c" read ch n = 0 i = `expr "$str" : ".*"` while [ $i - ne 0 ] do m = `echo $str|cut -c $i` if [ "$m" = "$ch" ]; then n = `expr $n + 1` fi i = `expr $i - 1` done echo "The frequency is :" $n
clear echo " Enter the Year: \c" read year echo " Enter the Month: \c" read month m = 0 case "$month" in 1 | jan ) m = 1 ;; 2 | feb ) m = 2 ;; 3 | mar ) m = 3 ;; 4 | apr ) m = 4 ;; 5 | may ) m = 5 ;; 6 | jun ) m = 6 ;; 7 | jul ) m = 7 ;; 8 | aug ) m = 8 ;; 9 | sep ) m = 9 ;; 10 | oct ) m = 10 ;; 11 | nov ) m = 11 ;; 12 | dec ) m = 12 ;; *) echo $month "is not a valid Month! Showing Calendar for " $year ;; esac if [ $m - ne 0 ] then cal $m $year else cal $year fi
echo "Enter pattern to be searched:\c" read pname echo "Enter file name :\c" read fname echo "Search for $pname from file $fname:" grep "$pname" $fname
echo "Enter the Resource name" read fname if ( test -s $fname ) then ls -l $fname if ( test -d $fname ) then echo "It is a directory" else echo "It is a file" fi if ( test -r $fname ) then echo "It is a readable" fi if ( test -w $fname ) then echo "It is writable" fi if ( test -x $fname ) then echo "It is executable" fi else echo "No such resource present" fi