使用相对于当前目录的路径在 Linux CLI 中递归列出文件

使用相对于当前目录的路径在 Linux CLI 中递归列出文件

问题描述:

这类似于 this question,但我想包含相对于 unix 中当前目录的路径.如果我执行以下操作:

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:

test1/file.txt
test2/file1.txt
test2/file2.txt

上面的代码会返回:

file.txt
file1.txt
file2.txt

如何使用标准 Unix 命令让它包含相对于当前目录的路径?

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

使用查找:

find . -name *.txt -print

在使用 GNU find 的系统上,与大多数 GNU/Linux 发行版一样,您可以省略 -print.

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