Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一堆文件,需要检查所有非空文件。我可以找到这些文件,例如通过运行
find *e* -maxdepth 1 -size +0 -print
但是如果我添加| less到上面,我只能看到文件列表,而不是文件本身。
| less
如果我手动将此文件列表作为less(less file1.e file2.e file3.e等)的参数,我会得到我想要的,但是这种麻烦。有什么方法可以将find的输出直接传递给less吗?
less file1.e file2.e file3.e
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.
-type f
find