The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Owner of file gets 'not owner' error for chgrp brizrobbo SUN Solaris 4 12-18-2007 05:30 PM
change owner of a file CBarraford UNIX for Dummies Questions & Answers 3 03-03-2007 11:37 PM
How to change the owner of the file? redlotus72 UNIX for Dummies Questions & Answers 1 09-21-2006 11:31 PM
determine owner directory permissions from within the directory Sniper Pixie Shell Programming and Scripting 4 03-07-2006 05:06 PM
changing owner & grp of a file Sabari Nath S UNIX for Advanced & Expert Users 1 09-27-2005 12:08 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-26-2008
unibboy unibboy is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 10
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
  #2 (permalink)  
Old 01-26-2008
nitin09 nitin09 is offline
Registered User
  
 

Join Date: Jul 2007
Location: India
Posts: 14
ls -al |awk ' { print $3 }'
  #3 (permalink)  
Old 01-26-2008
unibboy unibboy is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 10
thanks for that mate.

Can i be stupid to ask is there any other way to do it witout using the awk command
  #4 (permalink)  
Old 01-26-2008
lucaswoods lucaswoods is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 9
stat -c %U filename
  #5 (permalink)  
Old 01-26-2008
fpmurphy's Avatar
fpmurphy fpmurphy is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2003
Location: Florida
Posts: 1,861
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;
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 10:58 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0