I am currently writing a script that expects input to be keyed in, and I have to verify if the input is numeric or not.
#!/bin/sh
read input
echo $input | awk ' { if ( $0 ~ /[0-9]/ )
printf " input contains numerics only"
else printf " input is mixed mode " } '
The results of testing are as follows :
input result
123 numerics only
123a numerics only
a22 numerics only
How does one check if the whole input is numeric ??
#!/bin/sh
read input
echo $input | awk ' { if ( $0 ~ /[0-9]/ )
printf " input contains numerics only"
else printf " input is mixed mode " } '
The results of testing are as follows :
input result
123 numerics only
123a numerics only
a22 numerics only
How does one check if the whole input is numeric ??