![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Owner of file gets 'not owner' error for chgrp | brizrobbo | SUN Solaris | 4 | 12-18-2007 02:30 PM |
| change owner of a file | CBarraford | UNIX for Dummies Questions & Answers | 3 | 03-03-2007 08:37 PM |
| How to change the owner of the file? | redlotus72 | UNIX for Dummies Questions & Answers | 1 | 09-21-2006 08:31 PM |
| determine owner directory permissions from within the directory | Sniper Pixie | Shell Programming and Scripting | 4 | 03-07-2006 02:06 PM |
| changing owner & grp of a file | Sabari Nath S | UNIX for Advanced & Expert Users | 1 | 09-27-2005 09:08 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
determine owner of a file
Hello,
I am on a mission to determine the user of file. I have used the ls -l command but it displays permission, link, user, group, etc, but I just want to display just the name of user of a specified file. Many thanks |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
ls -al |awk ' { print $3 }'
|
|
#3
|
|||
|
|||
|
thanks for that mate.
Can i be stupid to ask is there any other way to do it witout using the awk command |
|
#4
|
|||
|
|||
|
stat -c %U filename
|
|
#5
|
|||
|
|||
|
Using Perl
Code:
use File::stat; use User::pwent; $filename = "$ARGV[0]"; $attrs = stat($filename); $pwattrs = getpwuid($attrs->uid); printf "Owner is %s (%d)\n", $pwattrs->name, $attrs->uid; |
|||
| Google The UNIX and Linux Forums |