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

查看:62
本文介绍了在Linux CLI中以相对于当前目录的路径递归列出文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这类似于这个问题,但我想在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天全站免登陆