Dae*_*yth 60
find dirname -not -empty -ls
假设 GNU 找到,我会使用。
Nif*_*fle 20
这对于find ls 来说是不够强大的。
find -maxdepth 1 -size +0 -print
Run Code Online (Sandbox Code Playgroud)
-maxdepth 1
- 这告诉 find 仅搜索当前目录,删除以查看所有子目录或更改数字以下降 2、3 或更多级别。
-size +0
这告诉 find 查找大小大于0
字节的文件。0
可以更改为您想要的任何尺寸。
-print
告诉 find 打印出它找到的文件的完整路径
编辑:
后期添加:您可能还应该添加-type f
上面的开关。这告诉 find 只查找文件。正如下面的评论中所指出的,-print
实际上并不需要切换。
MaQ*_*eod 12
ls -l | awk '{if ($5 != 0) print $9}'
Run Code Online (Sandbox Code Playgroud)
如果您打算使用ls
,则需要来自awk
.
ls 几乎没有过滤文件的选项:这不是它的工作。过滤文件是 shell 在简单情况下的工作(通过 globbing),而在复杂情况下则是 find 的工作。
在 zsh 中,您可以使用L
globbing 限定符仅保留大小大于 0 的文件(.
限定符限制为常规文件):
ls *(.L+0)
Run Code Online (Sandbox Code Playgroud)
其他 shell 的用户必须使用 find。使用 GNU find(主要在 Linux 上找到):
find -maxdepth 1 -type f ! -empty -exec ls {} +
Run Code Online (Sandbox Code Playgroud)
符合 POSIX 的方式是:
find . -type f -size +0c -exec ls {} + -o -name . -o -prune
Run Code Online (Sandbox Code Playgroud)
如果ls
不只是一个例子,而您只是想进行目视检查,您可以按大小排序:ls -S
。
归档时间: |
|
查看次数: |
78082 次 |
最近记录: |