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
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
 
    
     
    
    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.
 
    
    