mime类型文件_从命令行获取文件MIME类型

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/plain

file --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 numb

你可能感兴趣的:(linux,java,python,shell,ubuntu)