Linux – List all files in a directory recursively but exclude directories themselves

file searchfindlinuxsearch

Simple question, I'm running the following find command:

find . -type d \( -path ./.git -o   \
                  -path ./log -o    \
                  -path ./public -o \
                  -path ./tmp       \) \
                  -prune -o         \
                  -print

To list all the files in my directory, excluding the specified directories.

This works great, however, what I want to also do is exclude any actual directories from the output, so if there is a directory structure as follows:

test
  -- foo.text
  -- bar.text

when I run my command I'd like to see:

./test/foo.text
./test/bar.text

instead of:

.
./test
./test/foo.text
./test/bar.text

Can anybody help?

Best Answer

find . -type f

will do it. You can do exec if you want to operate on file names.

Related Question