title: How do i terminate my script if i don't get an expected integer value? - BASH Shell Script
body: <p>as i explained in the title, i need to terminate the exec. of my script if the input value is not an integer. Im getting the number from a positional parameter. Here is the code:</p>
  
  <pre><code>a=9
  kb=0
  var=$2
  var=${var:3:1}
  if [ ${#2} -ne 4 ]
  then
      echo "ethN is wrong"
      exit 1
  fi
  if [ "$var" -gt 10  -o "$var" -lt 0 ]
  then
      echo "N is wrong"
      exit 1
  else
      echo "N is ok"
  fi
  </code></pre>
  
  <p>when i use this entry: </p>
  
  <blockquote>
    <p>bash lartc.sh -i eth#</p>
  </blockquote>
  
  <p>My script is not ending and i want it to because the "#" from eth# is not an integer and this is what i want it to do. (e.g of valid input: eth2,eth3,etc...). However, my terminal says to me that "#" was expected to be an int. I'm validating length and that the number must be between 0-9, i just need to validate the type of it. Any ideas? thank you!</p>