16 August 2015

UNIX Shell script to know input is integer or not

Unix jobs, career
(Apply hot Unix jobs)
Unix Shell script to know input is integer or not.

$vi  prg1
clear
echo  "enter  a  number"
read  x
y='expr  $x  %  2'
if  test  $y  -eq  0
then
     echo  "Number  is  even"
else
    echo  "Number  is  odd"
fi

Running Script
$sh prg1
enter a number
11
Number is odd
$sh  prg1
enter  a  number
12
Number  is  even

No comments:

Post a Comment

Thanks for your message. We will get back you.

© 2010-2017 Biganalytics.me. All rights reserved.. Powered by Blogger.

Total Pageviews

All material, files, logos and trademarks within this site are properties of their respective organizations.