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 number of other informational use cases. Luckily the file command and and a flag is all you need!

MIME类型用于验证以及任何其他参考性用例。 幸运的是, file命令和标记是您所需要的!

翻译自: https://davidwalsh.name/get-mime-type

mime类型文件

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值