加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

linux – 如何在目录中查找二进制文件?

发布时间:2020-12-14 01:12:38 所属栏目:Linux 来源:网络整理
导读:我需要在目录中找到二进制文件.我想用文件做这个,然后我会用grep检查结果.但我的问题是我不知道什么是二进制文件.什么会给二进制文件的文件命令或我应该用grep检查什么? 谢谢. 解决方法 只需提及文本文件的Perl -T测试,以及二进制文件的相反-B测试. $find .
我需要在目录中找到二进制文件.我想用文件做这个,然后我会用grep检查结果.但我的问题是我不知道什么是二进制文件.什么会给二进制文件的文件命令或我应该用grep检查什么?

谢谢.

解决方法

只需提及文本文件的Perl -T测试,以及二进制文件的相反-B测试.

$find . -type f | perl -lne 'print if -B'

将打印出它看到的任何二进制文件.如果你想要相反的文本文件,请使用-T.

它并非完全万无一失,因为它只能看到前1000个字符左右,但它比这里建议的一些特殊方法更好.请参阅man perlfunc了解整个破坏.以下是摘要:

The “-T” and “-B” switches work as follows. The first block or so of the file is examined to see if it is valid UTF-8 that includes non-ASCII characters. If,so it’s a “-T” file. Otherwise,that same portion of the file is examined for odd characters such as strange control codes or characters with the high bit set. If more than a third of the characters are strange,it’s a “-B” file; otherwise it’s a “-T” file. Also,any file containing a zero byte in the examined portion is considered a binary file.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读