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

This forum is dedicated to basic help and support :

Ask here your questions about basic installation and usage of Mageia. For example you may post here all your questions about getting Mageia isos and installing it, configuring your printer, using your word processor etc.

Try to ask your questions in the right sub-forum with as much details as you can gather. the more precise the question will be, the more likely you are to get a useful answer

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

Postby Per » Jul 18th, '13, 08:27

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.
Last edited by Per on Jul 18th, '13, 13:22, edited 1 time in total.
Per
 
Posts: 24
Joined: Jul 30th, '11, 17:58

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

Postby filip » Jul 18th, '13, 08:57

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".
filip
 
Posts: 478
Joined: May 4th, '11, 22:10
Location: Kranj, Slovenia

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

Postby Mayavimmer » Jul 18th, '13, 09:59

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
Mayavimmer
 
Posts: 27
Joined: Nov 30th, '12, 10:17

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

Postby Per » Jul 18th, '13, 12:15

Thanks, exactly what I was looking for.
Per
 
Posts: 24
Joined: Jul 30th, '11, 17:58

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

Postby isadora » Jul 18th, '13, 12:41

Per, please mark the topic [SOLVED].
Thank you! :)
..........bird from paradise..........

Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
—Antoine de Saint-Exupéry
User avatar
isadora
 
Posts: 2766
Joined: Mar 25th, '11, 16:03
Location: Netherlands


Return to Basic support

Who is online

Users browsing this forum: No registered users and 1 guest