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

Comments

Popular Posts

The Growth of Machine Learning till TensorFlow

How to Fix Python Syntax Errors Quickly

7 AWS Interview Questions asked in Infosys, TCS

How to Use the ps Command in Linux

The best 5 differences of AWS EMR and Hadoop

Hyperledger Fabric: 20 Real Interview Questions

How to Decode TLV Quickly

AWS Vs Azure Load Balancers Top Insights

QlikView Server vs Publisher Top Differences Really Useful to Your Project

Top 10 SCALA Quiz Questions for Programmers