by reacweb · 7y ago · 0 comments
command -v brew >/dev/null && brew install jq hash foo &>/dev/null || { echo "foo command not found blabla..." >&2; exit 1; }
more info:
https://stackoverflow.com/questions/592620/how-to-check-if-a...command: command [-pVv] command [arg ...] Execute a simple command or display information about commands.
Runs COMMAND with ARGS suppressing shell function lookup, or display
information about the specified COMMANDs. Can be used to invoke commands
on disk when a function with the same name exists.
Options:
-p use a default value for PATH that is guaranteed to find all of
the standard utilities
-v print a description of COMMAND similar to the `type' builtin
-V print a more verbose description of each COMMAND
Exit Status:
Returns exit status of COMMAND, or failure if COMMAND is not found.I never knew about help to describe a builtin shell command. normally searching for something like "command" in the bash man page would be very tedious.
also: help echo
test (type brew 2>/dev/null); and brew # blahblah