One day a linux base command view file type

Source: Internet
Author: User

file View File Types

1 , command format

file [options] File ...

2 , command functions

This command is used to identify file types and to identify the encoding format of some files. It is to get the file type by looking at the header information of the file .

3 , common parameters

- b : Only the file identification results are listed and the file name is not displayed.

- F : View file types for file names in files, typically for Shell Programming

- I. : To MIME type to display the type of file

- Z : Try to interpret the contents of a compressed file

- F : Replaces the default ":" Delimiter after the output file name with the specified separator symbol.

- L : View file types for corresponding soft link files

4 , use instances

1 to view the corresponding file type for the specified file

command: File File

[[Email protected]~]# file inittab inittab:ascii 中文版 text[[email protected]~]# file test test:ascii text[[email Protec ted]~]# file Test inittab test:ascii textinittab:ascii 中文版 text[[email protected]~]#


2 , to MIME format to view file types

command: file-i File

[Email protected]~]# file-i inittab Inittab:text/plain; Charset=us-ascii[[email protected]~]#


3 , displays the file type specified in the file

command: file-f File

[Email protected]~]# cat test bashrc[[email protected]~]# file-f test. Bashrc:ascii Text[[email protected]~]#


4 , displays the file type of the corresponding soft connection

command: file-l Link_file

[Email protected]~]# file/dev/cdrom/dev/cdrom:symbolic link to ' sr0 ' [[Email protected]~]# file-l/dev/cdrom/dev/cdrom : Block Special[[email protected]~]# file/dev/sr0/dev/sr0:block special[[email protected]~]#

5 , try to interpret the compressed file

[[Email protected]~]# tar zcf test.tar.gz. *//To package and compress the files in the current directory into GZ format [e-mail protected]~]# lsinittab test test.tar.gz[[e Mail protected]~]# file-z test.tar.gz Test.tar.gz:POSIX tar archive (GNU) (gzip compressed data, from Unix, last modified : Tuedec 10:57:10) [[Email protected]~]# file test.tar.gz test.tar.gz:gzip compressed data, from Unix, last Modifie D:tue Dec 10:57:10 2016[[email protected]~]#


This article is from "Linux rookie" blog, please be sure to keep this source http://geekb0y.blog.51cto.com/10743719/1884184

One day a linux base command view file type

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.