找到隐藏的压缩文件并且大于大小
我了解到我可以使用以下方法找到大于 X 兆字节的文件:
$ find . -size +XM
但我隐藏了压缩文件(具有任何扩展名)(由 rar 和 zip 压缩),例如:
i_am_hidden.ink
这样当我尝试查看文件的 mimetype 时(在在这种情况下,是一个隐藏的 rar 文件):
$ file "i_am_hidden.ink" -b --mime-type
输出是:
application/x-rar
因此,linux 能够确定隐藏文件实际上是压缩文件。
如何在 shell(终端)上列出所有隐藏的压缩文件(给定路径目录)?
I've learned that I can locate files bigger than X megabytes using:
$ find . -size +XM
But I have hidden compressed files (with any extension) (compressed by rar and zip), like:
i_am_hidden.ink
so that when I try to see the mimetype of the file (in this case, a hidden rar file):
$ file "i_am_hidden.ink" -b --mime-type
the output is:
application/x-rar
So, linux is able to determine when a hidden file is actually a compressed file.
How, on shell (terminal), list all my hidden compressed files, given a path dir?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请注意,我删除了
file
的-b
标志,因为我希望同时输出文件名和 mime 类型。然后,awk
将解析输入,查找x-rar
并仅打印字段 #1 中的文件名。如果您的
find
版本抱怨-exec
,请尝试将+
替换为\;
。它会慢一些,但效果也一样。Note that I removed the
-b
flag tofile
because I want both the filename and the mime-type to output.awk
will then parse over the input looking forx-rar
and print just the file name which is in field #1.If your version of
find
complains about-exec
try replacing+
with\;
. It will be slower but it will work just as well.