Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ls command: how can I get a recursive full-path listing, one line per file?

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.

like image 905
dreftymac Avatar asked Nov 19 '09 23:11

dreftymac


People also ask

How do I list the full path of a file in Linux?

The pwd command displays the full, absolute path of the current, or working, directory. It's not something you'll use all the time, but it can be incredibly handy when you get a bit discombobulated. So there's a soft link with a source websites that points at a target /var/www. I cd using the soft link and enter pwd.

How do you get the full path of a file in Unix?

To use this command, simply type “readlink -f ” into your terminal then, type in the name of the file or folder that you want to find the path for and press enter. The output will be the file path of the specified file or folder.

Which ls command allows long listing format?

The -l option signifies the long list format.


1 Answers

Use find:

find . find /home/dreftymac 

If you want files only (omit directories, devices, etc):

find . -type f find /home/dreftymac -type f 
like image 136
stefanB Avatar answered Oct 21 '22 12:10

stefanB