commands

test — evaluate a condition

Bash test checks file, string and numeric expressions. Status zero means true, one means false; invalid expressions can fail with other statuses. Example assumes a fresh shell lab fixture with new output names.

Formal Syntax & Structure

linux syntaxlinux
test -f PATH

Parameters & Attributes

NameTypeDescription
-foptionregular file test
PATHoperandpath to inspect

Return Value

exit status and output

Bash test checks file, string and numeric expressions. Status zero means true, one means false; invalid expressions can fail with other statuses.

Working Example

Example Snippetlinux
if test -f notes.txt; then printf 'found\n'; fi
Linux Reference