set-option

noexec

Parse commands without executing them in a noninteractive shell. Does not verify runtime behavior or execute sourced modules.

Formal Syntax & Structure

bash syntaxbash
bash -n script; set -n

Return Value

shell option

Parse commands without executing them in a noninteractive shell. Does not verify runtime behavior or execute sourced modules.

Working Example

Example Snippetbash
printf '%s\n' 'printf "ready\\n" > result.txt' > demo.shbash -n demo.shprintf 'syntax=%s\n' "$?"[[ ! -e result.txt ]] && printf 'no result file\n'
Bash Reference