Require a dependency before running script logic.

Section: Files and Temporary Paths

Check if command exists

bash
bash
if ! command -v jq >/dev/null 2>&1; then echo 'jq required'; exit 1; fi
Explanation

Portable and very common in setup scripts.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Files and Temporary Paths
Create temp file
Create a secure temporary file.
OpenIn sheetbashsame section
Create temp directory
Create a secure temporary directory.
OpenIn sheetbashsame section
Copy file if contents differ
Avoid replacing files unnecessarily.
OpenIn sheetbashsame section
Walk up to repo root
Walk upward until a matching parent directory is found.
OpenIn sheetbashsame section
Portable Bash shebang
Use env to locate Bash on PATH.
Simple log function
Print timestamped log lines.