Fibonacci Range [Shell Program] Sumit Kar March 24, 2015 Shell Programming No comments echo "Enter therange"read ra=0b=1c=1echo "Fibonacciseries:\n"echo "$a $b\c"while [ $c -lt $r ]doc=`expr $a + $b`if [ $c -le $r ]thenecho "$c \c"fia=$bb=$cdoneecho "\n" Read More Share This: Facebook Twitter Google+ Stumble Digg WhatsApp
Fibonacci Series generator [Shell Program] Sumit Kar March 24, 2015 Shell Programming No comments echo "Enter the Number of Terms"read na=0b=1count=1n1=`expr $n - 2`if [ $n -eq 1 ]thenecho "TheFibonacci series is:"$aelif [ $n -eq 2 ]thenecho "TheFibonacci series is:"$a $belseecho "TheFibonacci series is:" echo "$a $b\c" while [ $count -le $n1 ]doc=`expr $a + $b`echo "$c \c"a=$bb=$ccount=`expr $count +1`donefiecho "\n" Read More Share This: Facebook Twitter Google+ Stumble Digg WhatsApp
Factorial of a Number [Shell Program] Sumit Kar March 24, 2015 Shell Programming No comments echo "Enter anumber"read nf=1if [ $n -eq 0 ]thenecho "Factorialis: 1"elsewhile [ $n -ge 1 ]dof=`expr $f \*$n`n=`expr $n - 1`doneecho "Factorialis:"$ffi Read More Share This: Facebook Twitter Google+ Stumble Digg WhatsApp
To the Power [Shell Program] Sumit Kar March 24, 2015 Shell Programming No comments echo "Enter theValue of x"read xecho "Enter theValue of y"read yr=1while [ $y -gt 0 ]dor=`expr $x \*$r` y=`expr $y - 1`doneecho "The valueof x^y is:"$r Read More Share This: Facebook Twitter Google+ Stumble Digg WhatsApp
Frequency of a Character in a String [Shell Program] Sumit Kar March 24, 2015 Shell Programming No comments clearecho "Enter theString:\c"read strecho "Enter thecharacter:\c"read chn=0i=`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`doneecho "Thefrequency is :" $n Read More Share This: Facebook Twitter Google+ Stumble Digg WhatsApp
Calculator [Shell Program] Sumit Kar March 24, 2015 Shell Programming No comments clearans=Ywhile [ "$ans" = "Y" ]doclearecho "*****MENU*****"echo "1.ADD"echo "2.SUBSTRACT"echo "3.MULTIPLY"echo "4.DIVIDE"echo "5.MOD"echo "0.EXIT"echo "Enter yourChoice"read chcase $ch in1) echo "Enter the1st number" read num1 echo "Enter the 2nd number" read num2 s=`expr $num1 + $num2` echo "The result:"$s;;2) echo "Enter the1st number" read num1 echo "Enter the 2nd number" read num2 s=`expr $num1 - $num2` echo "The result:"$s;;3) echo "Enter the1st number" read num1 echo "Enter the 2nd number" read num2 s=`expr $num1 \* $num2` echo "The result:"$s;;4) echo "Enter the1st number" read num1 echo "Enter the 2nd number" read num2 s=`expr $num1 / $num2` echo "The result:"$s;;5) echo "Enter the1st number" read num1 echo "Enter the 2nd number" read num2 s=`expr $num1 % $num2` echo "The result:"$s;;0) exit;;*) echo "WRONGCHOICE";;esacecho "Do you wantto continue?(Y/N)"read ansdone Read More Share This: Facebook Twitter Google+ Stumble Digg WhatsApp
Display the Calendar [Shell Program] Sumit Kar March 24, 2015 Shell Programming No comments clearecho " Enter theYear: \c"read yearecho " Enter theMonth: \c"read monthm=0case "$month" in1|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! ShowingCalendar for " $year ;;esacif [ $m -ne 0 ]thencal $m $yearelsecal $yearfi Read More Share This: Facebook Twitter Google+ Stumble Digg WhatsApp
Find a Pattern from a File [Shell Program] Sumit Kar March 24, 2015 Shell Programming No comments echo "Enterpattern to be searched:\c"read pnameecho "Enter filename :\c"read fnameecho "Search for$pname from file $fname:"grep "$pname" $fname Read More Share This: Facebook Twitter Google+ Stumble Digg WhatsApp
Resource Test [Shell Program] Sumit Kar March 24, 2015 Shell Programming No comments echo "Enter theResource name"read fnameif ( test -s $fname ) thenls -l $fnameif ( test -d $fname )then echo "It is adirectory"elseecho "It is afile"fiif ( test -r $fname )thenecho "It is areadable"fiif ( test -w $fname )then echo "It iswritable"fiif ( test -x $fname )thenecho "It isexecutable"fielseecho "No suchresource present"fi Read More Share This: Facebook Twitter Google+ Stumble Digg WhatsApp
Find the greatest among two numbers [Shell Program] Sumit Kar March 24, 2015 Shell Programming No comments echo "Enter 1st number :\c"read aecho "Enter 2nd number :\c"read bif [ $a -gt $b ] thenecho "$a greater than $b"elseecho "$b less than $a"fi Read More Share This: Facebook Twitter Google+ Stumble Digg WhatsApp