combining ls -R -l and find ?

roberttran

[H]ard|Gawd
Joined
Aug 15, 2002
Messages
1,471
I am trying to get a listing of all files in a directory with permissions and full path.

"ls -R -l /directory/" will list all items like:
Code:
/directory/:
total 2
-rwxr--r--  1 robert  wheel  228368384 Nov 29  2004 file1
-rwxr--r--  1 robert  wheel  230969344 Nov 29  2004 file2

/directory/subdir/:
total 2
-rwxr--r--  1 robert  wheel  231034880 Nov 29  2004 file3
-rwxr--r--  1 robert  wheel  230402048 Nov 29  2004 file4

"find /directory/" will list all items like:
Code:
/directory/file1
/directory/file2
/directory/subdir/file3
/directory/subdir/file4

I would like the files to be listed like:
Code:
-rwxr--r--  1 robert  wheel  228368384 Nov 29  2004 /directory/file1
-rwxr--r--  1 robert  wheel  230969344 Nov 29  2004 /directory/file2
-rwxr--r--  1 robert  wheel  231034880 Nov 29  2004 /directory/subdir/file3
-rwxr--r--  1 robert  wheel  230402048 Nov 29  2004 /directory/subdir/file4


I've tried combinations of piping ls into find or find into ls but I can't seem to figure it out.
Any tips? My end goal is to be able to send the output to a file that I can import into excel for reporting of directory/file permissions.

Thanks,
Robert
 
I know you have tried different combos of both, but have you tried to use 'ls' with no specific instructions on which files to output, and then pipe that to find?
 
Code:
$ find -printf "%M\t%u\t%g\t%p\n"
drwxr-xr-x      bugfood bugfood .
drwxr-xr-x      bugfood bugfood ./lib
drwxr-xr-x      bugfood bugfood ./usr
drwxr-xr-x      bugfood bugfood ./usr/bin
-rwxr-xr-x      bugfood bugfood ./usr/bin/lspci
drwxr-xr-x      bugfood bugfood ./usr/share
drwxr-xr-x      bugfood bugfood ./usr/share/misc
-rw-r--r--      bugfood bugfood ./usr/share/misc/pci.ids
-rw-r--r--      bugfood bugfood ./pciutils-udeb_2.2.4~pre4-1_amd64.udeb

Search the "find" manual for "printf format" to see other fields available for printing.

-Corey
 
Back
Top