Technocrat

  • Home
Showing posts with label Shell Programming. Show all posts
Showing posts with label Shell Programming. Show all posts

Tuesday, March 24, 2015

Fibonacci Range [Shell Program]

 Sumit Kar     March 24, 2015     Shell Programming     No comments   



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"











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 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"











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 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





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 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








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   



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


 





Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
  •  WhatsApp

Calculator [Shell Program]

 Sumit Kar     March 24, 2015     Shell Programming     No comments   



clear


ans=Y


while [ "$ans" = "Y" ]


do


clear


echo "*****MENU*****"


echo "1.ADD"


echo "2.SUBSTRACT"


echo "3.MULTIPLY"


echo "4.DIVIDE"


echo "5.MOD"


echo "0.EXIT"


echo "Enter your
Choice"


read ch


case $ch in


1) echo "Enter the
1st number"


  
read num1


  
echo "Enter the 2nd number"


  
read num2


  
s
=`expr $num1 + $num2`


  
echo "The result:"$s;;


2) echo "Enter the
1st number"


  
read num1


  
echo "Enter the 2nd number"


  
read num2


  
s
=`expr $num1 - $num2`


  
echo "The result:"$s;;


3) echo "Enter the
1st number"


  
read num1


  
echo "Enter the 2nd number"


  
read num2


  
s
=`expr $num1 \* $num2`


  
echo "The result:"$s;;


4) echo "Enter the
1st number"


  
read num1


  
echo "Enter the 2nd number"


  
read num2


  
s
=`expr $num1 / $num2`


  
echo "The result:"$s;;


5) echo "Enter the
1st number"


  
read num1


  
echo "Enter the 2nd number"


  
read num2


  
s
=`expr $num1 % $num2`


  
echo "The result:"$s;;


0) exit;;


*) echo "WRONG
CHOICE"
;;


esac





echo "Do you want
to continue?(Y/N)"


read ans


done





Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
  •  WhatsApp

Display the Calendar [Shell Program]

 Sumit Kar     March 24, 2015     Shell Programming     No comments   



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











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 "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








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 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





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 a


echo "Enter 2nd number :\c"


read b


if [ $a -gt $b ]


then


echo "$a greater than $b"


else


echo "$b less than $a"


fi





Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
  •  WhatsApp
Older Posts Home

Pages

  • Home

Trending Now

  • Write a Program to Add two 3x3 Matrix using C
    #include<stdio.h> void main () { int a [ 3 ][ 3 ], b [ 3 ][ 3 ], s [ 3 ][ 3 ], i , j ; printf ( "Enter the values of ...
  • C program for Unit Conversion
    /* Convert Celsius to Fahrenheit */ #include<stdio.h> void main() {     float c,f;     printf("Enter the temperature in Celcius: ...
  • Addition of two numbers on Server sent from Client [TCP] using C
    /* tcpClient.c */ #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #inc...
  • Write a Program to Print the Truth Table of Basic Gates using C
  • Write a Program to Add two 5x5 Matrix using C
    #include<stdio.h> void main() {   int a[5][5],b[5][5],c[5][5];   int i,j;   for(i=0;i<5;i++)   {     printf("\nEnter elements ...
  • Using the concept of Inheritance write a C++ Program to calculate the area and perimeter of rectangle
    /* C++ Program to calculate the area and perimeter of rectangles using concept of inheritance. */ #include using namespace std; class Re...
  • Concatenation of two strings sent from Client on the Server - [ TCP ] using C
    /* tcpClient.c */ #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #inc...
  • 8085 Programming: Exchange the contents of memory locations
    Exchange the contents of memory locations 2000H and 4000H. Program 1: LDA 2000H : Get the contents of memory location 2000H into accumulator...
  • Calculate Depreciation using C
    #include<conio.h> #include<stdio.h> void main () { float sv , pv , dep ; int yos ; clrscr (); printf ( "Enter the pu...
  • 8085 Programming: 1's COMPLEMENT OF A 16-BIT NUMBER
    The 16bit number is stored in C050,C051 The answer is stored in C052,C053   LXI H,C050   MOV A,M   CMA   STA C052   INX H   MOV ...

Blog Archive

  • ▼  2020 (1)
    • ▼  May (1)
      • Automating your deployments using Ansible
  • ►  2015 (92)
    • ►  October (4)
    • ►  September (3)
    • ►  August (3)
    • ►  July (9)
    • ►  June (9)
    • ►  May (20)
    • ►  April (7)
    • ►  March (22)
    • ►  February (7)
    • ►  January (8)
  • ►  2014 (158)
    • ►  November (70)
    • ►  October (6)
    • ►  September (82)
Powered by Blogger.

Categories

C - Programming Java Programming Basic Technology 8085 Assembly Programming For Loop Numerical Methods WhatsApp Algorithm Shell Programming Programming Networking Windows Android C++ Programming CPP If Else Tricky Internet Microsoft Pattern Photography Socket Program News While Loop Array DBMS DS Macro Recursion User Defined Function Conditional Operator Data Structure Durga Puja Earthquake Google Mela Nokia SQL Share Yahoo Airtel Bio Command Prompt Confused Facebook Finance Firefox Ganges Graph HokKolorob Input Kolkata MCQ Math Matrix NetNeutrality Oracle Religion Search Sumit Kar Survey Switch Case Viral Virus Visual Studio do-while featured featured_slider

Popular Programs

  • Write a Program to Add two 3x3 Matrix using C
    #include<stdio.h> void main () { int a [ 3 ][ 3 ], b [ 3 ][ 3 ], s [ 3 ][ 3 ], i , j ; printf ( "Enter the values of ...
  • C program for Unit Conversion
    /* Convert Celsius to Fahrenheit */ #include<stdio.h> void main() {     float c,f;     printf("Enter the temperature in Celcius: ...
  • Addition of two numbers on Server sent from Client [TCP] using C
    /* tcpClient.c */ #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #inc...
  • Write a Program to Print the Truth Table of Basic Gates using C
  • Write a Program to Add two 5x5 Matrix using C
    #include<stdio.h> void main() {   int a[5][5],b[5][5],c[5][5];   int i,j;   for(i=0;i<5;i++)   {     printf("\nEnter elements ...
  • Using the concept of Inheritance write a C++ Program to calculate the area and perimeter of rectangle
    /* C++ Program to calculate the area and perimeter of rectangles using concept of inheritance. */ #include using namespace std; class Re...
  • Concatenation of two strings sent from Client on the Server - [ TCP ] using C
    /* tcpClient.c */ #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #inc...
  • 8085 Programming: Exchange the contents of memory locations
    Exchange the contents of memory locations 2000H and 4000H. Program 1: LDA 2000H : Get the contents of memory location 2000H into accumulator...
  • Calculate Depreciation using C
    #include<conio.h> #include<stdio.h> void main () { float sv , pv , dep ; int yos ; clrscr (); printf ( "Enter the pu...
  • 8085 Programming: 1's COMPLEMENT OF A 16-BIT NUMBER
    The 16bit number is stored in C050,C051 The answer is stored in C052,C053   LXI H,C050   MOV A,M   CMA   STA C052   INX H   MOV ...

Daily Hits

Copyright © Sumit Kar