Question : Hot to determine if file exists in path

I need to determine if the command 'ec2-describe-volumes' is accessible, the problem is the location of the file could change because it's in a folder determined via the path variable.
I tried the following but it doesn't check the path:

if [ ! -e ec2-describe-volumes ]; then
  echo "file is missing"
  exit
fi

Answer : Hot to determine if file exists in path

I'd do it like
1:
2:
3:
4:
5:
if ! type ec2-describe-volumes >/dev/null 2>&1
then
  echo "ec2-describe-volumes command not found"
  exit 1
fi
Open in New Window Select All
Random Solutions  
 
programming4us programming4us