How can I get ls to spit out a flat list of recursive one-per-line paths?
For example, I just want a flat listing of files with their full paths:
/home/dreftymac/.
/home/dreftymac/foo.txt
/home/dreftymac/bar.txt
/home/dreftymac/stackoverflow
/home/dreftymac/stackoverflow/alpha.txt
/home/dreftymac/stackoverflow/bravo.txt
/home/dreftymac/stackoverflow/charlie.txt
ls -a1
almost does what I need, but I do not want path fragments, I want full paths.
@ghostdog74: Little tweak with your solution.
Following code can be used to search file with its full absolute path.
A lot of answers I see. This is mine, and I think quite useful if you are working on Mac.
I'm sure you know there are some "bundle" files (.app, .rtfd, .workflow, and so on). And looking at Finder's window they seem single files. But they are not. And
$ ls
or$ find
see them as directories... So, unless you need list their contents as well, this works for me:Of course this is for the working dir, and you could add other bundles' extensions (but always with a
/
after them). Or any other extensions if not bundle's without the/
.Rather interesting the "
.lpdf/
" (multilingual pdf). It has normal ".pdf
" extension (!!) or none in Finder. This way you get (or it just counts 1 file) for thispdf
and not a bunch of stuff…Don't make it complicated. I just used this and got a beautiful output:
If you really want to use
ls
, then format its output using awk:Handy for some limited appliance shells where find/locate aren't available.
I don't know about the full path, but you can use
-R
for recursion. Alternatively, if you're not bent onls
, you can just dofind *
.