Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get a list of files with full path

Tags:

unix

ls

I would like to get a list of all the files in a directory hierarchy (like I would with ls -R), but such that instead of listing the name of the directory and its files beneath it, it would just output a list of files with their full path. Is this possible?

like image 808
Amir Rachum Avatar asked Mar 13 '11 07:03

Amir Rachum


1 Answers

Use find for this type of thing.

find /home/me/subdir

will list all the files and directories, with full path, that live in /home/me/subdir.

find /home/me/subdir -type f

will only list files. (-type d for directories.)

If you need to match a filename glob, do like this:

find /home/me/subdir -type f -name "abc*"

Or exclude a file name pattern:

find /home/me/subdir -type f ! -name ".*"
like image 198
Mat Avatar answered Oct 03 '22 10:10

Mat