0

In xxx.sh, I need to execute a command. But if this command is not found, I want to throw an error.

if [[ xxxxxxx ]]; then
    echo "sorry xx command not found"
    exit 1
fi
HaveNoDisplayName
  • 8,291
  • 106
  • 37
  • 47
taotao
  • 55
  • 4

1 Answers1

0

From this answer:

In summary:

Where bash is your shell/hashbang, consistently use hash (for commands) or type (to consider built-ins & keywords).

When writing a POSIX script, use command -v.

Community
  • 1
  • 1
serge-sans-paille
  • 2,109
  • 11
  • 9