if [ condition ]; then ... fi

Category: Bash Scripting

if [ condition ]; then ... fi

Basic if statement syntax

Basic if statement structure in bash. The condition goes inside [ ] and fi closes the if block.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.