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.
Adding a wildcard to the end of an ls directory forces full paths. Right now you have this:
You could do this instead:
Unfortunately this does not print the full path for directories recursed into, so it may not be the full solution you're looking for.
If the directory is passed as a relative path and you will need to convert it to an absolute path before calling find. In the following example, the directory is passed as the first parameter to the script:
I think for a flat list the best way is:
(or in order to save it in a txt file)
Run a bash command with the following format:
Try the following simpler way:
Oh really a long list of answers. It helped a lot and finally I created by own which I was looking for :
To List All the Files in a directory and its sub-directories:
To List All the Directories in a directory and its sub-directories:
To List All the Directories and Files in a directory and its sub-directories: