Page 1 of 1

[SOLVED] Recursive full-path listing, one line per file

PostPosted: Jul 18th, '13, 08:27
by Per
I want to list the contents of one or more directories recursively with complete pathnames to all files. Say that I have the following files
    /home/name/one/directory/foo.txt
    /home/name/another/directory/bar.txt
    /home/name/antoher/directory/second bar.txt
What I want is to be able to list the contents of both directories with a long listing (-l) and then manipulate that listing with sort or grep or whatever. The closest I've gotten by searching the web is:
Code: Select all
ls -ld $(find /home/name/one/directory/) $(find /home/name/antoher/directory/)

The only problem I've found so far is that it doesn't work with filenames with spaces.

Re: Recursive full-path listing, one line per file

PostPosted: Jul 18th, '13, 08:57
by filip
Per wrote:The only problem I've found so far is that it doesn't work with filenames with spaces.


Use quotes like "/home/name/antoher/directory/second bar.txt".

Re: Recursive full-path listing, one line per file

PostPosted: Jul 18th, '13, 09:59
by Mayavimmer
Use find's -ls switch. It gives you all of ls -lR's fields, plus a couple more, and a better, filter-style ungrouped linear output:
Code: Select all
find /home/name/one/directory /home/name/antoher/directory -ls

Re: Recursive full-path listing, one line per file

PostPosted: Jul 18th, '13, 12:15
by Per
Thanks, exactly what I was looking for.

Re: Recursive full-path listing, one line per file

PostPosted: Jul 18th, '13, 12:41
by isadora
Per, please mark the topic [SOLVED].
Thank you! :)