recursive directory listing with ownership


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers recursive directory listing with ownership
# 1  
Old 01-30-2009
recursive directory listing with ownership

i'm playing around with "ls" and "find" and am trying to get a print out of directories, with full path, (recursive) and their ownership.... without files or package contents (Mac .pkg or .mpkg files). I'd like it simply displayed without much/any extraneous info.

everything i've tried, and researched, either presents too much info or not enough. generally, this format would be ideal but i'm open to other ideas...

eg:

owner:group /directoryA/
owner:group /directoryA/directory1/
owner:group /directoryB/
owner:group /directoryB/directory1/
owner:group /directoryB/directory2/
owner:group /directoryB/directory2/directory1/

thanks!
# 2  
Old 01-30-2009
Try this:

find . -ls | awk '{print $3,$5,$6,$11}' | grep "^d" | awk '{print $2,$3,$4}'
# 3  
Old 01-30-2009
Code:
find <path> -type d -printf "%u:%g %p\n"

Pipe it into 'sort' if you need it sorted, as find usually doesn't do that.
# 4  
Old 01-30-2009
---
find . -ls | awk '{print $3,$5,$6,$11}' | grep "^d" | awk '{print $2,$3,$4}'
---

awesome, thanks for the quick response! that's pretty darn close to what i was wanting...

it seems to not list directories with spaces in the name. "Address Book" is shortened to "Address".

thanks!
# 5  
Old 01-30-2009
This should fix the problem with space(s) in filename

find . -ls | awk '{printf "%s %s %s ", $3, $5, $6; for (i = 11; i <= NF; i++) printf "%s ", $i; printf "\n"}' | grep "^d" | cut -c 12-
# 6  
Old 01-30-2009
Quote:
Originally Posted by ce9888
This should fix the problem with space(s) in filename

find . -ls | awk '{printf "%s %s %s ", $3, $5, $6; for (i = 11; i <= NF; i++) printf "%s ", $i; printf "\n"}' | grep "^d" | cut -c 12-

great, thanks!!!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

How to set multiple ownership permission on a file/directory?

Hi, Any ideas to set multiple ownership permission on a file/directory on Solaris? I need a folder to have multiple ownership on the 2 nodes servers. The 2 nodes servers require to mount a SMBFS with different user ID. Please assist. Thanks. (6 Replies)
Discussion started by: freshmeat
6 Replies

2. Shell Programming and Scripting

[Perl] Module for recursive listing of remote Windows shares

Hi, I'm looking for a Perl module which can recursively list remote Windows shares from within a Linux machine. I've tried Filesys::SmbClient ans Filesys:SmbClientPars but they just list the current directory Thank You for your help (4 Replies)
Discussion started by: Fundix
4 Replies

3. UNIX for Dummies Questions & Answers

Change ownership of a directory

I want to change the ownership of a directory ONLY. my id id1 owns the files under the /mypath/bin but /mypath/bin is owned by id2 If i log into id2 I can't do chown id1 /mypath/bin (1 Reply)
Discussion started by: klarue
1 Replies

4. Solaris

User's Home directory ownership is changing Automatically

Hi , on my Solaris 10 machine user's home directory ownership is being changed automatically to their UID. can any one please tell me whats the reason behind it . users are there in /etc/passwd file . /etc/shadow file is also there along with nssswitch.conf file and there is no changes made to... (5 Replies)
Discussion started by: usernew
5 Replies

5. UNIX for Dummies Questions & Answers

Setting default directory file permissions and ownership help

I'm trying to setup a directory structure for my staff which enables them full access to files in the directories with their name, and have access to anything in the shared directory. The directory structure looks like this: root@www10 # ls -l total 56 drwxr-xr-x 7 internal internal 4096... (3 Replies)
Discussion started by: v_greg
3 Replies

6. UNIX for Dummies Questions & Answers

Ownership of files in bin directory

When I checked to see who or what owns the files in my bin directory I noticed that some were owned by root while many others were owned by bin. Should I be concerned that there are files in this directory owned by bin or is bin the same as root as it pertains to limiting access to the files in... (3 Replies)
Discussion started by: j490428
3 Replies

7. UNIX for Dummies Questions & Answers

copy directory without changing ownership setting

hi currently i am migrating some directories over to a new server. is there any command (rcp or ftp or anything) for me to use without changing the ownership and permission of the directory? i am copying some directories from unix machine to linux machine. what is the exact command? thanks... (2 Replies)
Discussion started by: legato
2 Replies

8. UNIX for Dummies Questions & Answers

Files in work directory reverting to root ownership

Hi, I have a problem with a Unix server we do not adminster but have an application running on. The problem is that overnight, files in the /user4/work directory revert to root ownership. This causes problems as we cannot process the files. 1) What would be causing files to revert to root... (1 Reply)
Discussion started by: canman
1 Replies

9. UNIX for Dummies Questions & Answers

Recursive directory listing without listing files

Does any one know how to get a recursive directory listing in long format (showing owner, group, permission etc) without listing the files contained in the directories. The following command also shows the files but I only want to see the directories. ls -lrtR * (4 Replies)
Discussion started by: psingh
4 Replies

10. UNIX for Dummies Questions & Answers

How do I change ownership of a directory and all of it's files.

How do I change ownership of a directory and all of it's files without changing permissions? (1 Reply)
Discussion started by: mborin
1 Replies
Login or Register to Ask a Question