繁体   English   中英

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 . -type f -exec basename {} \\;

甚至:

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

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

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

如何使用find

find /root/main -type f

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM