linux命令之file -凯发app官方网站

凯发app官方网站-凯发k8官网下载客户端中心 | | 凯发app官方网站-凯发k8官网下载客户端中心
  • 博客访问: 6397849
  • 博文数量: 579
  • 博客积分: 1548
  • 博客等级: 上尉
  • 技术积分: 16635
  • 用 户 组: 普通用户
  • 注册时间: 2012-12-12 15:29
个人简介

http://www.csdn.net/ http://www.arm.com/zh/ https://www.kernel.org/ http://www.linuxpk.com/ http://www.51develop.net/ http://linux.chinaitlab.com/ http://www.embeddedlinux.org.cn http://bbs.pediy.com/

文章分类

全部博文(579)

文章存档

2018年(18)

2015年(91)

2014年(159)

2013年(231)

2012年(80)

相关博文
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·

分类: linux

2018-09-07 16:58:00

用途说明

file命令是用来检测并显示文件类型(determine file type)。

常用参数

-b  不显示文件名称,只显示文件类型。在shell脚本中时有用。

-i     显示mime类别。

-l  直接显示符号连接所指向的文件的类别。

-f namefile    指定名称文件(namefile),该文件每一行为一个文件名,file命令将按每一行的文件名辨别该文件的类型

使用示例

示例一 显示文件类型

[root@web ~]# file install.log
install.log: utf-8 unicode text
[root@web ~]# file -b install.log      <== 不显示文件名称
utf-8 unicode text
[root@web ~]# file -i install.log      <== 显示mime类别。
install.log: text/plain; charset=utf-8
[root@web ~]# file -b -i install.log
text/plain; charset=utf-8
[root@web ~]#

示例二 显示符号链接的文件类型

[root@rhel55 ~]# ls -l /var/mail
lrwxrwxrwx 1 root root 10 08-13 00:11 /var/mail -> spool/mail

[root@rhel55 ~]# file /var/mail
/var/mail: symbolic link to `spool/mail'
[root@rhel55 ~]# file -l /var/mail
/var/mail: directory
[root@rhel55 ~]# file /var/spool/mail
/var/spool/mail: directory
[root@rhel55 ~]# file -l /var/spool/mail
/var/spool/mail: directory
[root@rhel55 ~]#

 

示例三

[root@web186 root]# file *
1.sh:                                      ascii text
1.txt:                                     empty
20080308xzmf.txt:                          ascii text, with crlf line terminators
448fd15874b0dc51.wav:                      riff (little-endian) data, wave audio, itu g.711 a-law, mono 8000 hz
449110ba327b23c6.vox:                      8086 relocatable (microsoft)
600d.wav:                                  riff (little-endian) data, wave audio, microsoft pcm, 16 bit, stereo 44100 hz
anaconda-ks.cfg:                           ascii english text
banner.swf:                                data
commons-beanutils.jar:                     zip archive data, at least v1.0 to extract
cvs_accept.sh:                             bourne shell script text executable
data:                                      directory
employer0605.txt:                          non-iso extended-ascii text
getfirstfile.class:                        compiled java class data, version 49.0
getfirstfile.java:                         ascii java program text
helpfile:                                  c program text
httptunnel.zip:                            zip archive data, at least v2.0 to extract
iptables_man.txt:                          ascii english text, with overstriking
lnx61su_171.tar.gz:                        gzip compressed data, from unix
megamgr.bin.filepart:                      elf 32-bit lsb executable, intel 80386, version 1 (sysv), for gnu/linux 2.0.0, statically linked, stripped
megapr_linux_a02.tar.gz:                   gzip compressed data, was "megapr_linux_a02.tar", from win/32
mess0429.txt:                              iso-8859 text, with very long lines
smartmontools-5.36.tar.gz:                 gzip compressed data, from unix, max compression
sms.qunfa:                                 elf 32-bit lsb executable, intel 80386, version 1 (sysv), for gnu/linux 2.2.5, dynamically linked (uses shared libs), not stripped
sms.vip.cfg:                               iso-8859 text, with very long lines
top.txt:                                   ascii text, with crlf, lf line terminators
voice20061128.rar:                         rar archive data
vox2amr.sh:                                bourne-again shell script text executable
[root@web186 root]#

 

注:使用file命令显示出来的文件类型有些情况下不一定太准确,如上面黑体显示的.vox文件格式,应该是dialogic vox file格式的。

问题思考

1. 怎样自定义某种文件类型?

相关资料

【1】脚本学习

阅读(2052) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~
")); function link(t){ var href= $(t).attr('href'); href ="?url=" encodeuricomponent(location.href); $(t).attr('href',href); //setcookie("returnouturl", location.href, 60, "/"); }
网站地图