📄 ls.html
字号:
or if<b>-n</b>is given,they are replacedwith their associated numeric values using the format%u.<p>The<<i>date and time</i>>,field will contain the appropriatedate and timestamp of when the file was last modified.In the POSIX locale, the field is the equivalentof the output of the following<i><a href="date.html">date</a></i>command:<pre><code>date "+%b %e %H:%M"</code></pre>if the file has been modified in the last six months, or:<pre><code>date "+%b %e %Y"</code></pre>(where twospacecharacters are used between<b>%e</b>and<b>%Y)</b>if the file has not been modified in the last six months or if themodification date is in the future, except that, in both cases,the finalnewline characterproduced by<i><a href="date.html">date</a></i>is not included andthe output is as if the<i><a href="date.html">date</a></i>command were executed at thetime of the last modification date of the file rather than thecurrent time.When the LC_TIME locale category is not set tothe POSIX locale, a different format and order of presentationof this field may be used.<p>If the file is a character special or block special file, the size of thefile may be replaced with implementation-dependent information associatedwith the device in question.<p>If the pathname was specified as a<i>file</i>operand, it will be writtenas specified.<p>The file mode written under the<b>-l</b>,<b>-g</b>,<b>-n</b>and<b>-o</b>options consists of the following format:<p><code><tt>"%c%s%s%s%c"</tt>, <<i>entry type</i>>,<<i>owner permissions</i>>,<<i>group permissions</i>>,<<i>other permissions</i>>,<<i>optional alternate access method flag</i>></code><p>The<<i>optional alternate access method flag</i>>is a singlespace characterif there is no alternate or additionalaccess control method associated with the file;otherwise, a printable character is used.<p>The<<i>entry type</i>>character describes the type of file, as follows:<dl compact><dt>d<dd>Directory.<dt>b<dd>Block special file.<dt>c<dd>Character special file.<dt>p<dd>FIFO.<dt>-<dd>Regular file.</dl><p>Implementations may add other characters to this list to representother, implementation-dependent, file types.<p>The next three fields are three characters each:<dl compact><dt><<i>owner permissions</i>><dd>Permissions for the file owner class (see<b>file access permissions</b>inthe <b>XBD</b> specification, <a href="../xbd/glossary.html"><b>Glossary</b> </a> ).<dt><<i>group permissions</i>><dd>Permissions for the file group class.<dt><<i>other permissions</i>><dd>Permissions for the file other class.</dl><p>Each field has three character positions:<p><ol><li>Ifr,the file is readable; if "-", it is not readable.<p><li>Ifw,the file is writable; if "-", it is not writable.<p><li>The first of the following that applies:<dl compact><dt><b>S</b><dd>If in<<i>owner permissions</i>>,the file is not executable andset-user-ID mode is set.If in<<i>group permissions</i>>,the file is not executable and set-group-ID mode is set.<dt><b>s</b><dd>If in<<i>owner permissions</i>>,the file is executable andset-user-ID mode is set.If in<<i>group permissions</i>>,the file is executable and set-group-ID mode is set.<dt><b>x</b><dd>The file is executable or the directory is searchable.<dt><b>-</b><dd>None of the attributes ofS,sorxapplies.</dl><p>Implementations may add other characters to this list for the thirdcharacter position.Such additions will, however, be written inlower-case if the file is executable or searchable, and in upper-caseif it is not.<p></ol><p>If any of the<b>-l</b>,<b>-g</b>,<b>-n</b>,<b>-o</b>or<b>-s</b>options is specified,each list of files within the directory will bepreceded by a status line indicating the number of file systemblocks occupied by files in the directory in512-byte units, rounded up to the next integralnumber of units, if necessary.In the POSIX locale, the format is:<p><code><tt>"total %u\n"</tt>, <<i>number of units in the directory</i>></code><p>If more than one directory, or a combination of non-directory files anddirectories are written, either as a result of specifying multipleoperands, or the<b>-R</b>option, each list of files within a directory will be preceded by:<p><code><tt>"\n%s:\n"</tt>, <<i>directory name</i>></code><p>If this string is the first thing to be written, the firstnewlinecharacter is not written.This output precedes the number of units in the directory.<p>If the<b>-s</b>option is given, each file shall be writtenwith the number of blocks used by the file.Along with<b>-C</b>,<b>-1</b>,<b>-m</b>or<b>-x</b>,the number and aspace characterprecede the filename; with<b>-g</b>,<b>-l</b>,<b>-n</b>or<b>-o</b>,they precede each line describing a file.</blockquote><h4><a name = "tag_001_014_1299"> </a>STDERR</h4><blockquote>Used only for diagnostic messages.</blockquote><h4><a name = "tag_001_014_1300"> </a>OUTPUT FILES</h4><blockquote>None.</blockquote><h4><a name = "tag_001_014_1301"> </a>EXTENDED DESCRIPTION</h4><blockquote>None.</blockquote><h4><a name = "tag_001_014_1302"> </a>EXIT STATUS</h4><blockquote>The following exit values are returned:<dl compact><dt>0<dd>All files were written successfully.<dt>>0<dd>An error occurred.</dl></blockquote><h4><a name = "tag_001_014_1303"> </a>CONSEQUENCES OF ERRORS</h4><blockquote>Default.</blockquote><h4><a name = "tag_001_014_1304"> </a>APPLICATION USAGE</h4><blockquote>Many implementations use the equal sign(=)and the at sign(@)to denotesockets bound to the file system and symbolic links, respectively, for the<b>-F</b>option.Similarly, many historical implementations use thescharacter and thelcharacter to denote sockets and symbolic links,respectively, as the entry type characters for the<b>-l</b>option.<p>It is difficult for an application to use every part of the file modesfield of<i>ls</i><b>-l</b>in a portable manner.Certain file types and executablebits are not guaranteed to be exactly as shown, as implementations mayhave extensions.Applications can use this field to pass directly toa user printout or prompt, but actions based on its contents shouldgenerally be deferred, instead, to the<i><a href="test.html">test</a></i>utility.<p>The output of<i>ls</i>(with the<b>-l</b>and related options) contains information thatlogically could be used by utilities such as<i><a href="chmod.html">chmod</a></i>and<i><a href="touch.html">touch</a></i>to restore files to a known state.However, this information is presented in a formatthat cannot be used directly by those utilities or be easilytranslated into a format that can be used.A character has been added to the end of the permissionsstring so that applications will at least have an indicationthat they may be working in an area they do not understandinstead of assuming that they can translate the permissionsstring into something that can be used.Future issues or related documents may define oneor more specific characters to be used based on differentstandard additional or alternative access control mechanisms.<p>As with many of the utilities that deal with filenames,the output of<i>ls</i>for multiple files or in one of the long listing formatsmust be used carefully on systems where filenames cancontain embedded white space.Systems and system administratorsshould institute policies and user training to limit theuse of such filenames.<p>The number of disk blocks occupiedby the file that it reports varies depending on underlying filesystem type, block size units reported and the method ofcalculating the number of blocks.On some file system types,the number is the actual number of blocks occupied by the file(counting indirect blocks and ignoring holes in the file); onothers it is calculated based on the file size (usually makingan allowance for indirect blocks, but ignoring holes).</blockquote><h4><a name = "tag_001_014_1305"> </a>EXAMPLES</h4><blockquote>An example of a small directory tree being fully listed with<i>ls</i><b>-laRF</b><b>a</b>in the POSIX locale:<pre><code>total 11drwxr-xr-x 3 hlj prog 64 Jul 4 12:07 ./drwxrwxrwx 4 hlj prog 3264 Jul 4 12:09 ../drwxr-xr-x 2 hlj prog 48 Jul 4 12:07 b/-rwxr--r-- 1 hlj prog 572 Jul 4 12:07 foo*a/b:total 4drwxr-xr-x 2 hlj prog 48 Jul 4 12:07 ./drwxr-xr-x 3 hlj prog 64 Jul 4 12:07 ../-rw-r--r-- 1 hlj prog 700 Jul 4 12:07 bar</code></pre></blockquote><h4><a name = "tag_001_014_1306"> </a>FUTURE DIRECTIONS</h4><blockquote>The<b>-s</b>uses implementation-dependent units and cannot be used portably;it may be withdrawn in a future issue.<p>The IEEE PASC 1003.2 Interpretations Committee has forwarded concerns aboutparts of this interface definition to the IEEE PASC Shell and Utilities Working Groupwhich is identifying the corrections.A future revision of this specification will align withIEEE Std. 1003.2b when finalised.</blockquote><h4><a name = "tag_001_014_1307"> </a>SEE ALSO</h4><blockquote><i><a href="chmod.html">chmod</a></i>,<i><a href="find.html">find</a></i>,the <b>XSH</b> specification description of<i><a href="../xsh/sysstat.h.html"><sys/stat.h></a></i>.</blockquote><hr size=2 noshade><center><font size=2>UNIX ® is a registered Trademark of The Open Group.<br>Copyright © 1997 The Open Group<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]</font></center><hr size=2 noshade></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -