如何使用linux cmd在linux的所有目录中列出所有文件

问题描述 投票:0回答:2

我正在尝试使用bash脚本读取所有目录中的所有文件以及完整路径。试过ls -Rcmd,但未正确列出文件。

我的要求是输出应该具有文件完整路径的输出。

linux bash command
2个回答
3
投票

也许您想要默认情况下递归的find实用程序。

find . -type f

.表示当前密码/目录


0
投票

您可以使用find命令列出特定目录中的所有文件。

find /your_path/ -type f 2>/dev/null

/your_path/ : provide the path from where you will execute the command, the output will have the complete path of the files.

2>/dev/null : to suppress the STDERR

现在,您正在尝试使用ls -R列出所有子目录,因此这将无法满足您要实现的目标。

请参见man ls

   -R, --recursive
              list subdirectories recursively
© www.soinside.com 2019 - 2024. All rights reserved.