I want to exclude everything which is not a number coming from my variable:
Example:
good variable: 4564 or 332 or 1
bad variable: er0rr or E131 or KE1
I'm not sure how to make if statement to recognize that the output is a number.
I want to exclude everything which is not a number coming from my variable:
Example:
good variable: 4564 or 332 or 1
bad variable: er0rr or E131 or KE1
I'm not sure how to make if statement to recognize that the output is a number.
In BASH you can use this regex condition to check if variable n
contains only digits:
[[ "$n" =~ ^[[:digit:]]+$ ]]