Check existence of input argument in a Bash shell script
Asked 07 September, 2021
Viewed 621 times
  • 64
Votes

I need to check the existence of an input argument. I have the following script

if [ "$1" -gt "-1" ]
  then echo hi
fi

I get

[: : integer expression expected

How do I check the input argument1 first to see if it exists?

11 Answer