buccaneers
Programmer
Hello All,
I am stuck at a point where in i am to check for any non-numeric charaters in a variable. Is there a way to do it. I want to avoid using multiple if checks.
Basically i expect a variable to $VAR to contain only numeric values and if it contains any non numeric value it should exit.
I tried using echo $VAR | grep -cve[0-9]
but this one fails when VAR=Abc-123
Is there a way to do this in one line along the line of using nawk/awk.... I am sure there is a simple solution to it which i am unable to think of.
Any ideas/ solutions ?
Appreciate ur feedback
I am stuck at a point where in i am to check for any non-numeric charaters in a variable. Is there a way to do it. I want to avoid using multiple if checks.
Basically i expect a variable to $VAR to contain only numeric values and if it contains any non numeric value it should exit.
I tried using echo $VAR | grep -cve[0-9]
but this one fails when VAR=Abc-123
Is there a way to do this in one line along the line of using nawk/awk.... I am sure there is a simple solution to it which i am unable to think of.
Any ideas/ solutions ?
Appreciate ur feedback