Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Script to find the user of a file and permissions

Shell Programming and Scripting


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 08-12-2010   -   Original Discussion by ggayathri
ggayathri ggayathri is offline
Registered User
 
Join Date: Oct 2008
Last Activity: 5 September 2017, 11:43 AM EDT
Posts: 84
Thanks: 1
Thanked 0 Times in 0 Posts
Script to find the user of a file and permissions

I have a list of files in a.txt file. For each of the files listed in that file, I would like to obtain the owner of the file and also, the permissions associated with that file.
If possible, the group the owner belongs to as well.
Can someone help me with a script to find that out.
Sponsored Links
    #2  
Old Unix and Linux 08-12-2010   -   Original Discussion by ggayathri
methyl methyl is offline
Registered User
 
Join Date: Mar 2008
Last Activity: 8 June 2016, 9:58 PM EDT
Posts: 6,402
Thanks: 288
Thanked 676 Times in 645 Posts
Assuming you use a Bourne-type shell and that a.txt is a normal unix format text file with each line containing only a filename.


Code:
cat a.txt | while read filename
do
       ls -lad "${filename}"
done

Or


Code:
while read filename
do
      ls -lad "${filename}"
done < a.txt

Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
permissions to create log file from script cesarNZ Shell Programming and Scripting 3 06-09-2009 12:43 PM
How to find a user's file permissions ram123 UNIX for Dummies Questions & Answers 9 03-19-2009 03:29 PM
Find username of user running the script garric Shell Programming and Scripting 1 06-10-2008 04:44 AM
Find the user executing a script Chiefos UNIX for Dummies Questions & Answers 2 06-14-2006 04:40 PM
How to find permissions/roles/priveleges of User hardesh UNIX for Advanced & Expert Users 1 09-27-2005 10:22 AM



All times are GMT -4. The time now is 01:42 AM.