📄 file.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta name="generator" content="HTML Tidy, see www.w3.org"><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 --><!-- Copyright (c) 2001-2003 The Open Group, All Rights Reserved --><title>file</title></head><body bgcolor="white"><script type="text/javascript" language="JavaScript" src="../jscript/codes.js"></script><basefont size="3"> <a name="file"></a> <a name="tag_04_54"></a><!-- file --> <!--header start--><center><font size="2">The Open Group Base Specifications Issue 6<br>IEEE Std 1003.1, 2003 Edition<br>Copyright © 2001-2003 The IEEE and The Open Group, All Rights reserved.</font></center><!--header end--><hr size="2" noshade><h4><a name="tag_04_54_01"></a>NAME</h4><blockquote>file - determine file type</blockquote><h4><a name="tag_04_54_02"></a>SYNOPSIS</h4><blockquote class="synopsis"><div class="box"><code><tt><sup>[<a href="javascript:open_code('UP')">UP</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> file</tt> <b>[</b><tt>-dh</tt><b>][</b><tt>-M</tt> <i>file</i><b>][</b><tt>-m</tt> <i>file</i><b>]</b><i>file</i> <tt>...<br><br> file -i</tt> <b>[</b><tt>-h</tt><b>]</b> <i>file</i> <tt>... <img src="../images/opt-end.gif" alt="[Option End]" border="0"></tt></code></div><tt><br></tt></blockquote><h4><a name="tag_04_54_03"></a>DESCRIPTION</h4><blockquote><p>The <i>file</i> utility shall perform a series of tests in sequence on each specified <i>file</i> in an attempt to classifyit:</p><ol><li><p>If <i>file</i> does not exist, cannot be read, or its file status could not be determined, the output shall indicate that thefile was processed, but that its type could not be determined.</p></li><li><p>If the file is not a regular file, its file type shall be identified. The file types directory, FIFO, socket, block special, andcharacter special shall be identified as such. Other implementation-defined file types may also be identified. If <i>file</i> is asymbolic link, by default the link shall be resolved and <i>file</i> shall test the type of file referenced by the symbolic link.(See the <b>-h</b> and <b>-i</b> options below.)</p></li><li><p>If the length of <i>file</i> is zero, it shall be identified as an empty file.</p></li><li><p>The <i>file</i> utility shall examine an initial segment of <i>file</i> and shall make a guess at identifying its contents basedon position-sensitive tests. (The answer is not guaranteed to be correct; see the <b>-d</b>, <b>-M</b>, and <b>-m</b> optionsbelow.)</p></li><li><p>The <i>file</i> utility shall examine <i>file</i> and make a guess at identifying its contents based on context-sensitivedefault system tests. (The answer is not guaranteed to be correct.)</p></li><li><p>The file shall be identified as a data file.</p></li></ol><p>If <i>file</i> does not exist, cannot be read, or its file status could not be determined, the output shall indicate that thefile was processed, but that its type could not be determined.</p><p>If <i>file</i> is a symbolic link, by default the link shall be resolved and <i>file</i> shall test the type of file referencedby the symbolic link.</p></blockquote><h4><a name="tag_04_54_04"></a>OPTIONS</h4><blockquote><p>The <i>file</i> utility shall conform to the Base Definitions volume of IEEE Std 1003.1-2001, <a href="../basedefs/xbd_chap12.html#tag_12_02">Section 12.2, Utility Syntax Guidelines</a>, except that the order of the <b>-m</b>,<b>-d</b>, and <b>-M</b> options shall be significant.</p><p>The following options shall be supported by the implementation:</p><dl compact><dt><b>-d</b></dt><dd>Apply any position-sensitive default system tests and context-sensitive default system tests to the file. This is the defaultif no <b>-M</b> or <b>-m</b> option is specified.</dd><dt><b>-h</b></dt><dd>When a symbolic link is encountered, identify the file as a symbolic link. If <b>-h</b> is not specified and <i>file</i> is asymbolic link that refers to a nonexistent file, <i>file</i> shall identify the file as a symbolic link, as if <b>-h</b> had beenspecified.</dd><dt><b>-i</b></dt><dd>If a file is a regular file, do not attempt to classify the type of the file further, but identify the file as specified in theSTDOUT section.</dd><dt><b>-M </b> <i>file</i></dt><dd>Specify the name of a file containing position-sensitive tests that shall be applied to a file in order to classify it (see theEXTENDED DESCRIPTION). No position-sensitive default system tests nor context-sensitive default system tests shall be appliedunless the <b>-d</b> option is also specified.</dd><dt><b>-m </b> <i>file</i></dt><dd>Specify the name of a file containing position-sensitive tests that shall be applied to a file in order to classify it (see theEXTENDED DESCRIPTION).</dd></dl><p>If the <b>-m</b> option is specified without specifying the <b>-d</b> option or the <b>-M</b> option, position-sensitive defaultsystem tests shall be applied after the position-sensitive tests specified by the <b>-m</b> option. If the <b>-M</b> option isspecified with the <b>-d</b> option, the <b>-m</b> option, or both, or the <b>-m</b> option is specified with the <b>-d</b> option,the concatenation of the position-sensitive tests specified by these options shall be applied in the order specified by theappearance of these options. If a <b>-M</b> or <b>-m</b> <i>file</i> option-argument is <b>-</b>, the results are unspecified.</p></blockquote><h4><a name="tag_04_54_05"></a>OPERANDS</h4><blockquote><p>The following operand shall be supported:</p><dl compact><dt><i>file</i></dt><dd>A pathname of a file to be tested.</dd></dl></blockquote><h4><a name="tag_04_54_06"></a>STDIN</h4><blockquote><p>Not used.</p></blockquote><h4><a name="tag_04_54_07"></a>INPUT FILES</h4><blockquote><p>The <i>file</i> can be any file type.</p></blockquote><h4><a name="tag_04_54_08"></a>ENVIRONMENT VARIABLES</h4><blockquote><p>The following environment variables shall affect the execution of <i>file</i>:</p><dl compact><dt><i>LANG</i></dt><dd>Provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume ofIEEE Std 1003.1-2001, <a href="../basedefs/xbd_chap08.html#tag_08_02">Section 8.2, Internationalization Variables</a> forthe precedence of internationalization variables used to determine the values of locale categories.)</dd><dt><i>LC_ALL</i></dt><dd>If set to a non-empty string value, override the values of all the other internationalization variables.</dd><dt><i>LC_CTYPE</i></dt><dd>Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte asopposed to multi-byte characters in arguments and input files).</dd><dt><i>LC_MESSAGES</i></dt><dd>Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error andinformative messages written to standard output.</dd><dt><i>NLSPATH</i></dt><dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">Determine the location of message catalogs for the processing of <i>LC_MESSAGES .</i> <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd></dl></blockquote><h4><a name="tag_04_54_09"></a>ASYNCHRONOUS EVENTS</h4><blockquote><p>Default.</p></blockquote><h4><a name="tag_04_54_10"></a>STDOUT</h4><blockquote><p>In the POSIX locale, the following format shall be used to identify each operand, <i>file</i> specified:</p><pre><tt>"%s: %s\n", <</tt><i>file</i><tt>>, <</tt><i>type</i><tt>></tt></pre><p>The values for <<i>type</i>> are unspecified, except that in the POSIX locale, if <i>file</i> is identified as one of thetypes listed in the following table, <<i>type</i>> shall contain (but is not limited to) the corresponding string, unless thefile is identified by a position-sensitive test specified by a <b>-M</b> or <b>-m</b> option. Each space shown in the strings shallbe exactly one <space>.<br></p><center><b><a name="tagtcjh_14"></a> Table: File Utility Output Strings</b></center><center><table border="1" cellpadding="3" align="center"><tr valign="top"><th align="center"><p class="tent"><b>If <i>file</i> is:</b></p></th><th align="center"><p class="tent"><b><<i>type</i>> shall contain the string:</b></p></th><th align="center"><p class="tent"><b>Notes</b></p></th></tr><tr valign="top"><td align="left"><p class="tent">Nonexistent</p></td><td align="left"><p class="tent">cannot open</p></td><td align="left"><p class="tent"> </p></td></tr><tr valign="top"><td align="left"><p class="tent">Block special</p></td><td align="left"><p class="tent">block special</p></td><td align="left"><p class="tent">1</p></td></tr><tr valign="top"><td align="left"><p class="tent">Character special</p></td><td align="left"><p class="tent">character special</p></td><td align="left"><p class="tent">1</p></td></tr><tr valign="top"><td align="left"><p class="tent">Directory</p></td><td align="left"><p class="tent">directory</p></td><td align="left"><p class="tent">1</p></td></tr><tr valign="top"><td align="left"><p class="tent">FIFO</p></td><td align="left"><p class="tent">fifo</p>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -