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 PATHParameters & Attributes
| Name | Type | Description |
|---|---|---|
| -f | option | regular file test |
| PATH | operand | path 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