Shell command to retrieve file ownership of a determed file
Matthew B. Brookover
mbrookov at mines.edu
Thu Sep 7 14:33:09 UTC 2006
I have used stat because it is simple to store the information in
variables:
eval `stat -c 'MODE="%A";OWNER="%U";GROUP="%G"' afilenamegoeshere`
echo $MODE $OWNER $GROUP
Matt
On Thu, 2006-09-07 at 05:26 -0400, Michael Velez wrote:
>
> > -----Original Message-----
> > From: redhat-list-bounces at redhat.com
> > [mailto:redhat-list-bounces at redhat.com] On Behalf Of Martin Thoma
> > Sent: Thursday, September 07, 2006 3:36 AM
> > To: General Red Hat Linux discussion list
> > Subject: Shell command to retrieve file ownership of a determed file
> >
> > Hi
> >
> > I am writing a shell script that is verifies ownership and
> > the file access permissions of selected files. Is there a
> > tool that allows me to retrieve the uid,gid and mode directly
> > instead of 'ls -l | grep <filename> | cut -d" " ...'?
> >
> > Thanks for a hint.
> >
> > Cheers Martin
>
> The best thing I know of is not too much different from what you have:
>
> ls -l <filename> | awk '{print $1}'
> ls -l <filename> | awk '{print $3}'
> ls -l <filename> | awk '{print $4}'
>
> or ls -l <filename> | awk '{print $1" "$3" "$4}'
>
> Michael
>
More information about the redhat-list
mailing list