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

Linux - Print only filenames for the directory and sub-directories

我是 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:

find /root/main -type f

如何使用:

find . -type f -exec basename {} \;

甚至:

find . -type f -printf "%f\n"

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