使用相对于当前目录的路径在 Linux CLI 中递归列出文件 [英] List files recursively in Linux CLI with path relative to the current directory

查看:29
本文介绍了使用相对于当前目录的路径在 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.

这篇关于使用相对于当前目录的路径在 Linux CLI 中递归列出文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆