-2

I want to check function arguments, and check whether $2 and $3 are numeric Is the following line the way to use the AND statement? Am I using = the correct way to check for numeric digits?

if [[ "$2" = +([[:digit:]]) ]] && [[ "$3" = +([[:digit:]]) ]]; then
Vera
  • 1,223

1 Answers1

1

I suggest creating a function, perhaps called "IsInt", which returns true if the parameters passed is numeric. You would then say

if IsInt "$2" && IsInt "$3" ; then
...
fi

You then have the simpler task of creating "IsInt", or looking at an existing answer

icarus
  • 17,920