Is there a command to get the owner of a file?

At the moment I'm just using `ls -o` (with `cut`), but `ls` is obviously giving me a lot more output than just the file owner.

Try the stat command:

stat -c %U file

Regards

Thanks a lot, I didn't know about the `stat` command, but I was sure something like this must exist. The operators of the official Ubuntu support channel told me that parsing `ls` was the only way, haha.

So, stay tuned here... :wink:

Well yes, I get the impression that people actually know what they're talking about here and are not in the habit of spreading misinformation.

fyi - the stat command is not standard and does not exist on all UNIX variants. for example - AIX uses the istat command.

Well yes I had noticed that it resided in /usr/bin.

is fairly simple to make a c app that uses the stat() function of the <sys/stat.h> and just prints the stuff,

And even simpler with Perl, which tends to be installed most places these days.

but the following wins the award for being most simple

:slight_smile:

ls -l filename | awk {'print $3'}