mime类型文件
I've gotten skilled at shell scripting over the years. I love a good GUI but knowing how to automate makes you a much more powerful engineer. Much of my scripting requires recursing over directories and processing a file if it meets a given criteria, which is often file extension or MIME type.
这些年来,我已经精通Shell脚本。 我喜欢一个好的GUI,但是知道如何自动化可以使您成为功能更强大的工程师。 我的许多脚本编制工作都需要递归目录并在文件满足给定条件(通常是文件扩展名或MIME类型)时处理文件。
You can use the following shell command to get a file's MIME type:
您可以使用以下shell命令来获取文件的MIME类型:
file --mime-type -b Downloads/main.js# text/plainfile --mime-type -b Downloads/logo.jpg# image/jpeg
It's important to use the brief (-b
) option in the command or you may receive an error message.
在命令中使用简短( -b
)选项很重要,否则您可能会收到错误消息。
MIME type is used for validation and any number of other informational use cases. Luckily the file
command and and a flag is all you need!
MIME类型用于验证以及任何其他参考性用例。 幸运的是, file
命令和标记是您所需要的!
翻译自:
mime类型文件