Pages

Script to find if a number is odd or even using the command factor.

Here is linux shell script which will find if a number is even or odd using the command factor.



Save the script as oddEven.sh and execute it using bash.



The factor command basically lists all the factors of the number, and by using grep we search for 2 using the option -c to count if 2 is present count will be 1 , else it will be 0.

No comments:

Post a Comment