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
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
ls -al |awk ' { print $3 }'
thanks for that mate.
Can i be stupid to ask is there any other way to do it witout using the awk command
stat -c %U filename
Using Perl
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;