Amir Rachum
Amir Rachum

Reputation: 79735

Get a list of files with full path

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?

Upvotes: 13

Views: 26933

Answers (1)

Mat
Mat

Reputation: 206879

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 ".*"

Upvotes: 24

Related Questions