好记性不如铅笔头

linux, 操作系统

linux的file命令简单笔记

参考
http://www.cnblogs.com/lwgdream/p/3407740.html 】

http://linux.chinaitlab.com/command/723446.html 】

CONTENTS

介绍:

file命令可以获取多种文件类型,包括文本文件、脚本文件、源码文件、多媒体文件(音频视频)等。file是通过查看文件的头部内容,来获取文件的类型,而不像Window那样是通过扩展名来确定文件类型的。

例子:

# -b:列出辨识结果时,不显示文件名称。
changcheng@ubuntu:~/test$ file -b text.c
ASCII text
changcheng@ubuntu:~/test$ file text.c
text.c: ASCII text
changcheng@ubuntu:/$ file initrd.img
initrd.img: symbolic link to `boot/initrd.img-3.8.0-23-generic'
# -L:直接显示符号连接所指向的文件的类别。 
changcheng@ubuntu:/$ file -L initrd.img
initrd.img: gzip compressed data, from Unix, last modified: Sun Jun  9 17:40:09 2013
# -v:显示版本信息
changcheng@ubuntu:/$ file -v
file-5.11
magic file from /etc/magic:/usr/share/misc/magic
# 显示目录
hangcheng@ubuntu:~$ file test
test: directory
changcheng@ubuntu:~/test$ ls
test2  text.c  text.c.zip
# 显示本地所有文件的信息
changcheng@ubuntu:~/test$ file *
test2:      directory
text.c:     ASCII text
text.c.zip: Zip archive data, at least v1.0 to extract
# -z:尝试去解读压缩文件的内容。
changcheng@ubuntu:~/test$ file -z text.c.zip 
text.c.zip: ASCII text (Zip archive data, at least v1.0 to extract)

发表评论

3 × 4 =

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据