[CentOS] ls --author ?

Paul Heinlein heinlein at madboa.com
Mon Mar 20 16:42:51 UTC 2006

On Mon, 20 Mar 2006, James B. Byrne wrote:

> I want a script to determine the owner of a particular file and
> then "sudo -u <thatuserid> <somecomand>". I ran across the --author
> option of ls but that does not seem to give me anything useful.  It
> prints a short form of the filename without any other information
> at all.  In fact, the output of ls --author is indistinguishable
> from that of ls by itself:
>> # ls --author htdocs/*
>> htdocs/hlllogo.png
>> # ls htdocs/*
>> htdocs/hlllogo.png
>> #
> Is there a linux command that will return just the userid in a form
> that can be passed to sudo or do I have to parse ls -l <filename>?

stat -c %U filename

The stat(1) man page has format details; it's part of the coreutils 

Paul Heinlein <> heinlein at madboa.com <> www.madboa.com

More information about the CentOS mailing list