LS(1) — HP-UX
NAME
ls, l, ll, lsf, lsr, lsx − list contents of directories
SYNOPSIS
ls [ −abcdfgilmnopqrstuxACFR1 ] [ names ]
l [ ls options ] [ names ]
ll [ ls options ] [ names ]
lsf [ ls options ] [ names ]
lsr [ ls options ] [ names ]
lsx [ ls options ] [ names ]
DESCRIPTION
For each directory argument, ls lists the contents of the directory; for each file argument, 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.
If you are the super-user, all files except . and .. are listed by default.
There are three major listing formats. The format chosen depends on whether the output is going to a login device, 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. (When individual file names (as opposed to directory names) appear in the argument list, those file names are always sorted across the page rather than down the page in columns. This is because the individual file names may be arbitrarily long.) If the standard output is not a teletype, the default format is to list one entry per line, the −C and −x options enable multi-column formats, and the −m option enables stream output format in which files are listed across the page, separated by commas. In order to determine output formats for the −C, −x, and −m options, ls uses an environment variable, COLUMNS, to determine the number of character positions available on one output line. If this variable is not set, the terminfo database is used to determine the number of columns, based on the environment variable TERM. If this information cannot be obtained, 80 columns is assumed.
Options
There are numerous options:
−a List all entries; usually entries whose names begin with a period (.) are not listed.
−b Force printing of non-graphic characters to be in the octal \ddd notation.
−c Use time of last modification of the inode (file created, mode changed, etc.) for sorting (−t) or printing (−l).
−d If an argument is a directory, list only its name (not its contents); often used with −l to get the status of a directory.
−f Force each argument to be interpreted as a directory and list the name found in each slot. This option turns off −l, −t, −s, and −r, and turns on −a; the order is the order in which entries appear in the directory.
−g The same as −l, except that only the group is printed (owner is omitted.) (If both -l and -g are specified, the owner is not printed.)
−i For each file, print the i-number in the first column of the report.
−l List in long format, giving mode, number of links, owner, group, 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 rather than a size.
−m Stream output format.
−n The same as −l, except that the owner’s UID and group’s GID numbers are printed, rather than the associated character strings.
−o The same as −l, except that only the owner is printed (group is omitted.) (If both -l and -o are specified, the group is not printed.)
−p Put a slash (/) after each file name if that file is a directory.
−q Force printing of non-graphic characters in file names as the character (?).
−r Reverse the order of sort to get reverse alphabetic or oldest first as appropriate.
−s Give size in blocks, including indirect blocks, for each entry.
−t Sort by time modified (latest first) instead of by name.
−u Use time of last access instead of last modification for sorting (with the −t option) or printing (with the −l option).
−x Multi-column output with entries sorted across rather than down the page.
−A The same as −a, except that the current directory "." and parent directory ".." are not listed. For the super-user, this flag defaults to ON, and is turned off by −A.
−C Multi-column output with entries sorted down the columns.
−F Put a slash (/) after each file name if that file is a directory, and put an asterisk (*) after each file name if that file is executable.
−R Recursively list subdirectories encountered.
−1 The file names will be listed in single column format regardless of the output device. This will force single column format to the user’s terminal.
Ls normally is known by several names which provide shorthands for the various formats:
l is equivalent to ls −m.
ll is equivalent to ls −l.
lsf is equivalent to ls −F.
lsr is equivalent to ls −R.
lsx is equivalent to ls −x.
The shorthand notations are implemented as links to ls. Option arguments to the shorthand versions behave exactly as if the long form above had been used with the additional arguments.
The mode printed under the −l option consists of 10 characters. The first character is:
d if the entry is a directory;
b if the entry is a block special file;
c if the entry is a character special file;
l if the entry is a symbolic link;
p if the entry is a fifo (a.k.a. “named pipe”) special file;
n if the entry is a network special file;
− if the entry is an ordinary file.
The next 9 characters are interpreted as three sets of three bits each. The first set refers to the owner’s permissions, the next to permissions of others in the user-group of the file, and the last to all others. Within each set, the three characters indicate permission to read, to write, and to execute the file as a program, respectively. For a directory, “execute” permission is interpreted to mean permission to search the directory for a specified file. The permissions are indicated as follows:
r if the file is readable;
w if the file is writable;
x if the file is executable;
− if the indicated permission is not granted.
The group-execute permission character is given as s if the file has set-group-ID mode; likewise, the user-execute permission character is given as s if the file has set-user-ID mode. The last character of the mode (normally x or −) is t if the 1000 (octal) bit of the mode is on; see chmod(1) for the meaning of this mode. The indications of set-ID and 1000 bits of the mode are capitalized (S and T respectively), if the corresponding execute permission is not set.
When the sizes of the files in a directory are listed, a total count of blocks, including indirect blocks, is printed.
EXAMPLES
The following command prints a long listing of all the files (including the file sizes) in the current working directory. The file most recently modified (the youngest) is listed first, then the next youngest file, and so forth, to the oldest. Files beginning with a . are also printed.
ls -alst
WARNINGS
The option setting based on whether the output is a teletype is undesirable as ls −s is much different than ls −s | lpr. On the other hand, not using this setting would make old shell scripts that used ls almost inevitably fail.
Unprintable characters in file names may confuse the columnar output options.
DEPENDENCIES
Series 300 Diskless
An additional option is supported:
−H Put a plus sign (+) after each file name if that file is a hidden directory (context-dependent file). This option also implies −F. See cdf(4).
Series 500
The −a and −A options perform the same function.
AUTHOR
Ls was developed by AT&T, the University of California, Berkeley and HP.
FILES
/etc/passwd to get user IDs for ls −l and ls −o.
/etc/group to get group IDs for ls −l and ls −g.
/usr/lib/terminfo/?/* to get terminal information.
SEE ALSO
INTERNATIONAL SUPPORT
ls: 8-bit file names, messages.
Hewlett-Packard Company — Version B.1, May 11, 2021