我正在尝试使用bash脚本读取所有目录中的所有文件以及完整路径。试过ls -R
cmd,但未正确列出文件。
我的要求是输出应该具有文件完整路径的输出。
也许您想要默认情况下递归的find
实用程序。
find . -type f
.
表示当前密码/目录
您可以使用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