Featured Post

Thursday, March 24, 2016

shell program to check whether the given number is even or not


/*    evenodd.sh  */

echo "enter your number"
read num
m=`expr $num % 2
if [ m-eq 0 ]
 then
    echo "given number is even number"
  else
   echo "given number is odd number"
fi


/home/anil/~$ sh evenodd.sh
  enter your number
  25
   given number is odd




Note: if is a conditional statement in UNIX same like c programming but little bit equivalent changes.

if [ condition ]
then
     display statements
fi



every if followed by then and ends with fi


gt    - greater then
lt     -less then
le    -less then or equal
ge   -greater then or equal
ne   - not equal
eq     equal



if else condition works same like in other programming languages.


Unix operating system Linux operating system shell programming bourn shell kourne shell c shell difference between unix and linux operating system , history of UNIX, red hat operating system. UNIX OS architecture , kernel utility programs , file handling process handling inter process communication pipes shared memory message queues socket programming TCP/IP , UDP programming , One to One chat Application , Basic shell program to add two numbers , echo function , while loops clear gt lt le ge ne eq if fi while do done case array in unix strings , cut copy paste cat dir pwd getcwd chdir command read write stat lseek fstat flock mechanism.even or add program vi editor command ni vi editor command mode esc mode insert mode aa dd x :q :wq :w

No comments:

Post a Comment