Shell command to retrieve file ownership of a determed file
Martin Thoma
mthoma at schlagundrahm.ch
Thu Sep 7 09:35:00 UTC 2006
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
>
>
Thanks for your hint Michael. I am using now something like:
ls -l | awk '$9 ~ /<filename>/ {print $3, $4}'
Cheers
More information about the redhat-list
mailing list