One day a shell command Linux text Series-file command usage _linux shell

Source: Internet
Author: User
Tags printable characters uncompress zip

Introduction to Linux file commands:

This command is used to identify file types and to identify the encoding format of some files. It gets the file type by looking at the header information of the file, not as if Windows determines the file type by extension.

For more information you can view this article: http://www.jb51.net/LINUXjishu/388984.html

File official explanation: Determine type of FILEs. The type of the decision file.

Small knowledge: In Unix/linux systems, file types are not determined by extension (Windows Yes).

Opening example:

1. $file file.txt

Output: File.txt:ASCII 中文版 text

Note: File.txt is the help document I generated with file–help > file.txt

View-help

Copy Code code as follows:

Usage:file [OPTION ...] [FILE ...]
Determine type of FILEs.
--help Display this Help and exit
-V,--version output version information and exit
-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 don't 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
-E,--exclude test exclude test from the ' list of ' test to is performed for file. Valid tests Are:ascii, Apptype, compress, elf, soft, tar, tokens, troff
-F,--files-from file read the filenames to is examined from file
-F,--separator string use string as separator instead of ': '
-I,--mime output MIME type strings (--mime-type and
--mime-encoding)
--apple Output the Apple Creator/type
--mime-type Output the MIME type
--mime-encoding Output the MIME encoding
-K,--keep-going don ' t stop at the ' match
-L,--list list Magic strength
-L,--dereference follow symlinks (default)
-H,--no-dereference don ' t follow symlinks
-N,--no-buffer do not buffer output
-N,--no-pad do not pad output
-0,--print0 terminate filenames with ASCII NUL
-p,--preserve-date preserve access times on files
-R,--raw don ' t translate unprintable chars to \ooo
-S,--special-files treat special (Block/char devices) files as ordinary ones
-C,--compile compile file specified by-m
-D,--debug print debugging messages

Interpretation:

1.-Z

View information in a compressed file

2.-B, E,-i,–r

-B Remove prefix naming of output lines
-E from the test list to the executed file exclusion test. Valid tests include: ASCII, Apptype, compress, elf, soft, tar,
-I print MIME
-R does not interpret characters that cannot be printed as \ooo

3. Magic File

Files with MGC as extensions, Microsoft Office Media catalog files

Actual Combat Example:

1. $file-Z File.zip
View file information in a File.zip package

2. $file – I File.txt
Out:file.txt:text/plain; Charset=us-ascii

Print MIME type

$file file.txt
Out:file.txt:ASCII 中文版 Text

3. Magic File

My translation is really lame. can only guess see $which file look, no harvest. Finally get through $file

Usage:file [-bchikllnnprsvz0] [--apple] [--mime-encoding] [--mime-type]
[-E TestName] [F Separator] [F NameFile] [-M magicfiles] file ...
File-c [M Magicfiles]
file [--help]

Then try file–c get MAGIC.MGC file ... Don't know what to use, ashamed

Usage:file [OPTION ...] [FILE ...]
Determine type of FILEs.

--help Display this Help and exit
-V,--version output version information and exit
-M,--magic-file list with a colon-separated magical number list

-Z,--uncompress view compressed file contents
-B,--brief not prefix filename to output line
-C,--checking-printout print the analytic format of the Magic file, before installation, with-M debug a new Magic file

-E,--exclude test excludes tests from the test list to the execution file. Effective testing: ASCII, Apptype, compress, elf, soft, tar, tokens, troff
-F,--files-from file reads the file name from the document that was checked
-F,--separator string takes a string as a separator instead of ":"
-I,--mime output MIME type string (--mime-type and
--mime-encoding)

--apple output Apple Type Creator/type
--mime-type Print MIME type
--mime-encoding Print MIME encoding
K,--keep-going does not stop at the first match
-L,--list list Magic Depth
-L,--dereference follow symbolic link (default)
-H,--no-dereference does not follow symbolic links
-N,--no-buffer does not buffer output
-N,--no-pad does not print output
-0,--print0 nul terminate file
-P,--preserve-date keep the original access time on the file
-R,--raw does not transfer non-printable characters to \ooo
-S,--special-files treats Special (block/character device) files as normal files
-C,--compile compiled with-m-specified files
-D,--debug print debugging information

The bugs to http://bugs.gw.com/

Related Article

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.