Coreutils stat
have --format=
switch which report different info about file (owner, size, etc) in easy form for readers.
POSIX ls
utility provide most of this info, but its output is hard to parse. Compare with one-liner:
[ `stat -c '%U' $f` = $USER ] && echo "You own $f" || echo Error!
Are there stat
utility analog in POSIX?
The short answer is no, POSIX does not provide a simple way to get the same output as stat
. However, you can usually get relevant bits using other tools. To get the owner specifically:
ls -ld /path/of/file/or/directory | awk '{print $3}'