




全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Linux命令学习总结: file命令命令简介:该命令用来识别文件类型,也可用来辨别一些文件的编码格式。它是通过查看文件的头部信息来获取文件类型,而不是像Windows通过扩展名来确定文件类型的。执行权限 :All User指令所在路径:/usr/bin/file命令语法:file -bchikLnNprsvz -f namefile -F separator -m magicfiles file .命令参数:下表列出了部分常用的参数。参数长参数描叙-b列出文件辨识结果时,不显示文件名称。-c详细显示指令执行过程,便于排错或分析程序执行的情形-f列出文件中文件名的文件类型-F使用指定分隔符号替换输出文件名后的默认的“:”分隔符。-i输出mime类型的字符串-L查看对应软链接对应文件的文件类型-z尝试去解读压缩文件的内容-help显示命令在线帮助-version显示命令版本信息 使用示例:1:查看file命令的帮助信息rootDB-Server # file -helpUsage: file OPTION. FILE.Determine file type of FILEs. -m, -magic-file LIST use LIST as a colon-separated list of magic number files -z, -uncompress try to look inside compressed files -b, -brief do not prepend filenames to output lines -c, -checking-printout print the parsed form of the magic file, use in conjunction with -m to debug a new magic file before installing it -f, -files-from FILE read the filenames to be examined from FILE -F, -separator string use string as separator instead of : -i, -mime output mime type strings -k, -keep-going dont stop at the first match -L, -dereference causes symlinks to be followed -n, -no-buffer do not buffer output -N, -no-pad do not pad output -p, -preserve-date preserve access times on files -r, -raw dont translate unprintable chars to ooo -s, -special-files treat special (block/char devices) files as ordinary ones -help display this help and exit -version output version information and exit当然你也可以使用 man file 获取更加详细的帮助文档信息。2:查看文件类型例如,如下所示,Temp.txt 文件类型为text,编码为UTF-8 UnicoderootDB-Server # file Temp.txt Temp.txt: UTF-8 Unicode text, with very long lines, with CRLF line terminators 3:不输出文件名称,只显示文件格式以及编码通过下面两个命令对时,就可以清晰的了解参数-b的作用。rootDB-Server # file Temp.txt Temp.txt: UTF-8 Unicode text, with very long lines, with CRLF line terminatorsrootDB-Server # file -b Temp.txtUTF-8 Unicode text, with very long lines, with CRLF line terminators 4: 输出mime类型的字符串rootDB-Server # file -i Temp.txt Temp.txt: text/plain; charset=utf-8 5: 查看文件中的文件名的文件类型这个参数非常适合shell脚本去查找、判别某种文件类型的数据。rootDB-Server # cat test/root/install.logit is only one test file 2+ Stopped cat testrootDB-Server # file -f test/root/install.log: ASCII textit is only one test file: ERROR: cannot open it is only one test file (No such file or directory)rootDB-Server # rootDB-Server # 5: 使用指定分隔符号替换输出文件名后的默认的“:”分隔符。感觉这个参数很鸡肋!我搞明白这个参数的作用时,很是纳闷。 6:尝试去解读压缩文件的内容rootDB-Server # file -z Temp.txt.gz Temp.txt.gz: UTF-8 Unicode text, with very long lines, with CRLF line terminators (gzip compressed data, was Temp.txt, from Unix, last modified: Tue Jun 24 00:34:15 2014)rootDB-Server # 7: 查看软链接对应文件的文件类型如下所示,创建一个软链接sfile,然后分别用file 和带参数的file -L查看 rootDB-Server # ln -s Temp.txt.gz sfilerootDB-Server # file sfile sfile: symbolic link to Temp.txt
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 学校现金员管理制度
- 学校规范化管理制度
- 学生代管班管理制度
- 学生课间跑管理制度
- 安保部奖罚管理制度
- 宋朝对地方管理制度
- 定制类订单管理制度
- 实训室开放管理制度
- 审核相关方管理制度
- 客运驻站办管理制度
- 2025年新高考1卷(新课标Ⅰ卷)语文试卷
- 2025-2030中国设施管理服务行业市场发展趋势与前景展望战略研究报告
- 贵金属分析检测方法考核试卷
- 2025-2030离子注入机行业市场现状供需分析及投资评估规划分析研究报告
- 2022-2023学年北京市朝阳区人教版五年级下册期末测试数学试卷(原卷版+解析)
- 外包管理安全管理制度
- 人形机器人深度研究系列八:谐波减速器:差齿传动持续进化
- 公立医院风险评估报告
- 新标准外研版三年级英语期末复习计划
- 教育机构采购管理流程优化
- 肿瘤妇科进修汇报
评论
0/150
提交评论