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

👤 Login to reply

    #1  
Old 08-12-2010
ggayathri ggayathri is offline
Registered User
 
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 08-12-2010
methyl methyl is offline
Registered User
 
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
👤 Login to reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 11:43 AM
How to find a user's file permissions ram123 UNIX for Dummies Questions & Answers 9 03-19-2009 02:29 PM
Find username of user running the script garric Shell Programming and Scripting 1 06-10-2008 03:44 AM
Find the user executing a script Chiefos UNIX for Dummies Questions & Answers 2 06-14-2006 03:40 PM
How to find permissions/roles/priveleges of User hardesh UNIX for Advanced & Expert Users 1 09-27-2005 09:22 AM



All times are GMT -4. The time now is 05:04 AM.

Unix & Linux Forums Content Copyright©1993-2018. All Rights Reserved.
×
UNIX.COM Login
Username:
Password:  
Show Password





Not a Forum Member?
Forgot Password?