file-test
Bash -ot — older modification time
Checks whether the first file has an earlier modification timestamp than the second, or does not exist while the second does. Equal timestamps are false. Check existence separately if both files must be present. Run the example independently in a fresh private directory. Expected output (one item per line): older=0; missing-left=0; equal=1.
Formal Syntax & Structure
bash syntaxbash
[[ path1 -ot path2 ]]Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| path1 | path | First pathname. |
| path2 | path | Second pathname. |
Return Value
exit status
0 for a true condition; 1 for a false condition. Invalid expressions may fail differently.
Working Example
Example Snippetbash
touch -t 202001010000 oldtouch -t 202001020000 new[[ old -ot new ]]; printf 'older=%s\n' "$?"[[ missing -ot new ]]; printf 'missing-left=%s\n' "$?"[[ old -ot old ]]; printf 'equal=%s\n' "$?"