我有一堆文件,需要检查所有非空文件。我可以找到这些文件,例如通过运行
find *e* -maxdepth 1 -size +0 -print
但是如果我将
| less
添加到上面,我只能看到文件列表,而不是文件本身。如果我手动将此文件列表作为参数提供给 less (
less file1.e file2.e file3.e
等)我得到了我想要的,但这种麻烦。有什么办法可以将 find 的输出直接通过管道传输到 less 吗? 最佳答案
依次在每个文件上运行 less
:
find *e* -type f -maxdepth 1 -size +0 -exec less {} \;
或者:
find *e* -type f -maxdepth 1 -size +0 | xargs less
在整个列表上运行
less
(假设文件数量不是很大 - xargs 通常将最大参数限制为 5000)。请注意,添加
-type f
以便您不会从 find
返回目录。关于shell - 我可以将文件从 find 传送到 less 吗?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16520485/