Linux-只打印目录和子目录的文件名



我是Linux世界的新手。

我的linux上有以下目录(centos rhel fedora"(:

Folder_Root:
/root/main
/root/main/files
/root/main/files/file_1.txt
/root/main/files/file_2.ssh
/root/main/files/file_2.txt
/root/main/file_3.txt

我正在尝试打印所有目录中的所有文件。基本上,我正在尝试获得以下列表:

file_1.txt
file_2.ssh
file_2.txt
file_3.txt

我已经尝试了"ls"命令和"ls-al":but it prints also the direcotry name.

我还尝试使用"ls-lR|more":but it prints a lot of details that I don't want to use.

你推荐什么命令吗?

如何使用:

find . -type f -exec basename {} ;

甚至:

find . -type f -printf "%fn"

这里有一个类似的问题,它有很多答案,希望这有帮助:

仅列出bash 中目录和子目录中的文件名

如何使用find:

find /root/main -type f

相关内容

最新更新