.th LS VI 9/3/77 .sh NAME ls \- list contents of directory .sh SYNOPSIS .bd ls [ .bd \-lntasdruifm1cqx ] name ... .sh DESCRIPTION For each directory argument, .it ls lists the contents of the directory; for each file argument, .it ls repeats its name and any other information requested. The output is sorted alphabetically by default. When no argument is given, the current directory is listed. When several arguments are given, the arguments are first sorted appropriately, but file arguments appear before directories and their contents. .s3 .it Ls has three possible listing formats. The format chosen depends on whether the output is going to a teletype, and may also be controlled by option flags. The default format for a teletype is to list the contents of directories in multi-column format, with the entries sorted down the columns. (See also the .bd \-x option below.) If the standard output is not a teletype, the default format is to list one entry per line. This is the way older versions of .it ls worked. Finally, there is a stream output format in which files are listed across the page, separated by `,' characters. The .bd \-m flag enables this format. .s3 .bd "Important note:" Files which are not the contents of a directory being interpreted are always sorted across the page rather than down the page in columns. This is because the individual file names may be arbitrarily long. .s3 There are scads of options: .s3 .lp +4 4 \fB\-l\fR list in long format, giving mode, number of links, owner, size in bytes, and time of last modification for each file. (See below.) If the file is a special file the size field will instead contain the major and minor device numbers. .s3 .lp +4 4 \fB\-n\fR long format like \fB\-l\fR but without looking up the string name of the owner; the owner is given as decimal group and user id. This is much faster on a system with a large password file when many different people own the files being listed. .s3 .lp +4 4 \fB\-t\fR sort by time modified (latest first) instead of by name, as is normal .s3 .lp +4 4 \fB\-a\fR list all entries; usually those beginning with `\fB.\fR' are suppressed .s3 .lp +4 4 \fB\-s\fR give size in blocks for each entry. If l is also specified the size in blocks appears after the size in bytes. .s3 .lp +4 4 \fB\-d\fR if argument is a directory, list only its name, not its contents (mostly used with .bd \-l to get status on directory) .s3 .lp +4 4 \fB\-r\fR reverse the order of sort to get reverse alphabetic or oldest first as appropriate .s3 .lp +4 4 \fB\-u\fR use time of last access instead of last modification for sorting (\fB\-t\fR) or printing (\fB\-l\fR) .s3 .lp +4 4 \fB\-i\fR print i-number in first column of the report for each file listed .s3 .lp +4 4 \fB\-f\fR force each argument to be interpreted as a directory and list the name found in each slot. This option turns off .bd \-l, .bd \-t, .bd \-s, and .bd \-r, and turns on .bd \-a; the order is the order in which entries appear in the directory. .s3 .lp +4 4 \fB\-m\fR force stream output format .s3 .lp +4 4 \fB\-1\fR force one entry per line output format, e.g. to a teletype .s3 .lp +4 4 \fB\-c\fR force multi-column output, e.g. to a file or a pipe .s3 .lp +4 4 \fB\-q\fR force printing of non-graphic characters in file names as the character `?'; this normally happens only if the output device is a teletype .s3 .lp +4 4 \fB\-x\fR force columnar printing to be sorted across rather than down the page; this is the default if the last character of the name the program is invoked with is not an `l' or an `s'. .s3 .i0 The mode printed under the .bd \-l option contains 7 characters which are interpreted as follows: the first character is .s3 .lp +3 3 \fBd\fR if the entry is a directory; .lp +3 3 \fBq\fR if the entry is a quota file; .lp +3 3 \fBb\fR if the entry is a block-type special file; .lp +3 3 \fBc\fR if the entry is a character-type special file; .lp +3 3 \fB\-\fR if the entry is a plain file. .s3 .i0 The next 6 characters are interpreted as two sets of three bits each. The first set refers to owner permissions; and the second to others. Within each set the three characters indicate permission respectively to read, to write, or to execute the file as a program. For a directory, `execute' permission is interpreted to mean permission to search the directory for a specified file. The permissions are indicated as follows: .s3 .lp +3 3 \fBr\fR if the file is readable .lp +3 3 \fBw\fR if the file is writable .lp +3 3 \fBx\fR if the file is executable .lp +3 3 \fB\-\fR if the indicated permission is not granted .s3 .i0 The user-execute permission character is given as .bd s if the file has set-user-ID mode. .s3 The last character of the mode is printed as ``t'' if the 1000 bit of the mode is on. See .it "chmod (I)" for the current meaning of this mode. .sh FILES /etc/passwd to get user ID's for \fBls \-l\fR. .sh BUGS Newline and tab are considered printing characters in file names. .s3 Output device is assumed to be 80 columns wide. Columns are basically 15 characters wide, 20 characters wide if \fB\-i\fR or \fB\-s\fR is specified, 25 characters wide if both \fB\-i\fR and \fB\-s\fR are specified. In any case where \fB\-l\fR or \fB\-n\fR is specified, we assume only one entry will fit per line. .s3 The option setting based on whether the output is a teletype is undesirable as: .s3 .dt ls \-s | lpr .s3 is much different than .s3 ls \-s .s3 On the other hand, not doing this setting would make old shell scripts which used .it ls almost certain losers, and then one could no longer do, e.g.: .s3 ls \-s | sort \-nr .s3 but would have to do .s3 ls \-s \-1 | sort \-nr