Pejman Moghadam / Scripts

Check if a variable is integer

Public domain


#!/bin/bash
VAR="2000"
if [ $(echo "$VAR" | grep -E "^[0-9]+$") ]; then
  echo $VAR IS a valid integer.
else
  echo $VAR is NOT a valid integer.
fi

BY: Pejman Moghadam
TAG: bash-script, bash
DATE: 2011-08-23 15:00:25


Pejman Moghadam / Scripts [ TXT ]