0% found this document useful (0 votes)
8 views2 pages

Shell Program for Even or Odd Check

The document provides a shell program that checks if a number is even or odd using an if-else statement. It also outlines the syntax for if-else, switch-case, while loops, and for loops in shell scripting. Additionally, it mentions writing a menu-based shell program and checking for prime numbers.

Uploaded by

darghya12345
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

Shell Program for Even or Odd Check

The document provides a shell program that checks if a number is even or odd using an if-else statement. It also outlines the syntax for if-else, switch-case, while loops, and for loops in shell scripting. Additionally, it mentions writing a menu-based shell program and checking for prime numbers.

Uploaded by

darghya12345
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

write a shell program check even or odd:

echo "ENter a number:"


read n
if [ `expr $n % 2` -eq 0 ]
then
echo $n is even
else
echo $n is odd
fi

-eq - equal to
-le less than equal to
-ge greater than equal to
-gt greater than

*** if else syntax ***


if command is successful
then
execute commnads
else
execute commands
fi

if command is successful
then
execute commads
fi

if command is successful
then
execute commands
elif commands is successful
then ...
elif ...
then...
fi

*** switch case ***

case expression in
pattern1) commands1 ;;
pattern2) commands2 ;;
....
....
....
esac

*** while loop ***


while condition is true
do commands
done

*** for loop ***


for variable in list
do
commands
done

*** write a menu based shell program ***


for the following list of
files of proccess of users todays date user of system

*** whether number is prime number ***

You might also like