file-test
Bash -O — effective user ownership
Checks whether the path is owned by the effective user ID of the shell, not whether the user has write access. A newly created private file normally belongs to the creating effective user. Run the example independently in a fresh private directory. Expected output (one item per line): owned=0; missing=1.
Formal Syntax & Structure
bash syntaxbash
[[ -O path ]]Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| path | path | File or directory pathname to inspect. |
Return Value
exit status
0 for a true condition; 1 for a false condition. Invalid expressions may fail differently.
Working Example
Example Snippetbash
touch sample[[ -O sample ]]; printf 'owned=%s\n' "$?"[[ -O missing ]]; printf 'missing=%s\n' "$?"