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.
Here is a partial answer that shows the directory names.
Explanation:
ls -mR *
lists the full directory names ending in a ':', then lists the files in that directory separatelysed -n 's/://p'
finds lines that end in a colon, strip off the colon and print the lineBy iterating over the list of directories, we should be able to find the directories as well. Still workin on it. It is a challenge to get the wildcards through xargs.
ls -lR
is what you were looking for, or atleast I was. cheersI knew the file name but wanted the directory as well.
find $PWD | fgrep filename
worked perfectly in Mac OS 10.12.1
find / will do the trick
This is slow but works recursively and prints both directories and files. You can pipe it with awk/grep if you just want the file names without all the other info/directories:
Using no external commands other than ls: