Darryl Hein Darryl Hein - 1 year ago 83
Linux Question

List files recursively in Linux CLI with path relative to the current directory

This is similar to this question, but I want to include the path relative to the current directory in unix. If I do the following:

ls -LR | grep .txt

It doesn't include the full paths. For example, I have the following directory structure:


The code above will return:


How can I get it to include the paths relative to the current directory using standard Unix commands?

Answer Source

Use find:

find . -name \*.txt -print

On systems that use GNU find, like most GNU/Linux distributions, you can leave out the -print.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download