if [ -O file ] then echo "File is owned by you" fi
if [ -n "$(find file -prune -user "$(id -u)")" ] then echo "File is owned by you" fi
test -O is a bash/ksh/dash/ash extension to check whether the file is owned by you.
test -O
To ensure compatibility with other shells, you can use find -user "$(id -u)".
find -user "$(id -u)"
If you expect your shell to support test -O, specify this explicitly in the shebang (or with # shellcheck shell=dash directive).
# shellcheck shell=dash
There was an error while loading. Please reload this page.