How to list only files and not directories of a directory Bash?

前端 未结 9 1052
旧巷少年郎
旧巷少年郎 2020-12-07 21:54

How can I list all the files of one folder but not their folders or subfiles. In other words: How can I list only the files?

9条回答
  •  一生所求
    2020-12-07 22:11

    Just adding on to carlpett's answer. For a much useful view of the files, you could pipe the output to ls.

    find . -maxdepth 1 -type f|ls -lt|less
    

    Shows the most recently modified files in a list format, quite useful when you have downloaded a lot of files, and want to see a non-cluttered version of the recent ones.

提交回复
热议问题