I want to write program to check whether the given input is number or not. Can anyone help me?
if [ $Number -ne 0 -o $Number -eq 0 2>/dev/null ]
then ...
and what -o stands for in above command?
-o is the or operator. So your test check if your number is not equal to 0 or if it's equals to 0.
(so it should always return true).
To check if it's a number, you could use a regexp: this should be working:
[[ "$number" =~ ^[0-9]+$ ]]
To see the list of all available flags, you should look at man test
Details:
[[ is a extended bash test command. It supports more operator than test/[.=~ compare the first argument again a regular expression^[0-9]+$ is the regular expression. ^ is an anchor for the start of the string, $ for the end. [0-9] means any char between 0 and 9, and + is for the repetition of the latest pattern