file commands are used to identify file types and to identify the encoding format of some files. It does this by looking at the header information of the file to get the file type, rather than identifying the file type as Windows does by extension.
1 . Command format:
file [-BCHIKLNNPRSVZ] [-F NameFile] [-F separator] [-M magicfiles] file ...
2 . Command function:
used to view time information such as a calendar, such as a single parameter, indicates the year (1-9999) , if there are two parameters, the month and year
3 . Command parameters:
- b???????? When listing file identification results, the file name is not displayed.
- c???????? detailed instruction execution process to facilitate troubleshooting or analysis of program execution Scenarios
- F???????? list file types for file names in Files
- F???????? replaces the default ":" Delimiter after the output file name with the specified separator symbol.
- I.???????? Output MIME type of String
- L???????? view file types for corresponding soft link files
- z???????? try to interpret the contents of a compressed file
--help???? Show commands online Help
-version???? Display Command version information
4 . Usage Examples:
Example 1: Viewing file types
Command:
File Temp.txt
Output:
????
Example 2: Do not output file name, only show file format and encoding
Command:
File–b Temp.txt
Output:
?
Example 3: Output MIME-type string
Command:
File–i Temp.txt
Output:
?
Example 3: Viewing file types for file names in files
Command:
File-f Test
Output:
?
Example 4: Replace the default ":" Delimiter after the output file name with the specified separator symbol.
Command:
File–f "--" test
Output:
?
Example 5: Try to interpret the contents of a compressed file
Command:
File–z test.gz
Output:
?
Example 6: Viewing the file type of a soft link file
Command:
????????file -L sfile
Output:
?
?
?
Detailed Linux commands-file