Mac:如何递归查找子目录中最大的文件(忽略所有目录)

Dan*_*lan 5 command-line macos

我有一个名为 的目录root。它具有深层嵌套的子目录。在这些子目录中,有一堆文件。我想找到 中最大的文件root

我根本不想找到目录。我不关心最大目录的大小,我只想找到最大的文件。

root
|
- subdir1
  |
  - small file 1
  - large file 1
  - small file 2
  ... lots more files      
- subdir2
  |
  - small file 3
  - large file 2
Run Code Online (Sandbox Code Playgroud)

我想打印出来large file 1large file 2. 我不希望它打印出有关root, subdir1, 或 的任何内容subdir2,即使它们比large file 1或更大2。这对我来说只是噪音。

如何在 Mac 上通过命令行执行此操作?

fd0*_*fd0 8

让我们ls进行排序->

find . -type f -exec ls -S {} + | head -n10
Run Code Online (Sandbox Code Playgroud)

  • 很好,但它不允许我看到文件的大小。`-Sl` 会更好 (5认同)