如何检测.o / .a /编译对象/可执行c/c++没有扩展名? (然后发出“what”on file 以查看它是用什么编译的)
如何检测文件是否是编译对象(.o .a(库))或可执行文件(没有文件扩展名)?
我想这样做,以便我可以发出标准的 What 命令来查看使用哪些 .c / .h 文件来构建二进制文件。
大概在文件的开头会有某种标头或其他一些模式来寻找(?)
已经在这里和其他地方看了一点,但答案往往是关于 MIME 类型和 Web 开发/处理此类文件:
How can I detect if a file is a compiled object ( .o .a (library)) or executable, without the file extension?
I want to do this so that I can then issue the standard what command to see what .c / .h files were used to build the binary.
Presumably there would be some kind of header at the beginning of the file or some other pattern to look for (?)
Had a look around here and elsewhere a little already but the answers tend to be about MIME types and web development / handling of such files:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用的是 Unix/Linux,
file
命令对于确定文件的文件类型非常有用,而无需依赖文件扩展名。它会查看诸如“这是一个特殊设备而不是普通文件”之类的内容,然后查找标识某些文件格式的“幻数”等。
If you're in Unix/Linux, the
file
command is useful for determining file type of files without relying on a file extension.It looks at things like "is this a special device rather than a normal file", then looks for "magic numbers" which identify certain file format, etc.