home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 11 Util
/
11-Util.zip
/
utlos2.zip
/
Doc
/
ls.doc
< prev
next >
Wrap
Text File
|
1998-02-07
|
14KB
|
314 lines
$Id: ls.doc 1.9 1998/02/08 02:00:27 brian Exp $
ls.doc : The ls command
By: Brian E. Yoder.
(c) Copyright International Business Machines Corporation 1998
All rights reserved.
The ls (list directory) command is a loose adaptation of the AIX ls
command, and is a better DIR command than DIR. It supports multiple
file specifications on the command line. It matches filenames using
the AIX Bourne shell pattern matching rules and not the DOS or OS/2
"wildcard" rules. See pattern.doc for a description of filename
matching patterns.
The ls command lists the names of ordinary files, hidden files, system
files, and directories as you wish. It also lists each name with any
drive and path information that was in the original file
specification. It can recursively descend subdirectories looking for
matching files and or directories if you wish.
In the "long" format, the ls command displays each file's attributes
as well as its size, date, and time.
By default, ls sorts the output by filename, and displays the names in
multicolumn format if standard output is a character device, just as
AIX does.
These features are found in the Win32, DOS, and OS/2 versions of ls!
========================================================================
Command usage
========================================================================
Invoke the command as follows:
ls [ -flags ] [ -- ] [ fspec ... ]
The flags are optional. If specified, they must consist of a dash
followed by one or more contiguous flag characters. The flags control
what names are listed and in what format they are listed.
If no flags are specified, then -fdn is assumed: list all matching
ordinary files and directories, and sort them by name.
Zero or more file specifications may be entered. Each file
specification consists of an optional drive, optional path, and
filename. Each filename may contain AIX shell pattern-matching
characters (better than DOS's and OS/2's wildcard characters). The ls
command lists all files in the specified directory whose names match
the filename, according to the -flags.
If a file specification is that of a directory, then ls appends '\*'
to it and matches everything in that directory. If there are no file
specifications, then ls assumes '*': match everything in the current
directory.
The following (case-sensitive) flag characters are supported:
-f List all ordinary (including readonly) files that match the file
specification(s). If the f flag is specified, then directories
are not listed unless the d flag is also specified.
-s List all system files.
-h List all hidden files.
-d List all subdirectories that match the file specification(s). If
the d flag is specified, then ordinary files are not listed
unless the f flag is also specified.
-a List all ordinary files, system files, hidden files, directories,
the . and .. directories, and, for DOS only, volume ids.
-l List each matching file or directory name in "long" format. For
each name, it also displays the attributes, size, time stamp,
and date stamp. If -l is not specified, the ls command lists
only the names.
-c Use time of creation instead of time of last modification. If
used with -l, it shows this time. If used with -t, it sorts
using this time. (Win32 and OS/2 versions only.)
-u Use time of last access instead of time of last modification.
If used with -l, it shows this time. If used with -t, it sorts
using this time. (NTFS and HPFS only.)
-x The same as -u, for compatibility with previous versions of ls.
-R Recursively descend subdirectories.
-p Put a path separator after each name that is a directory.
-C Force multicolumn output. The ls command tries to list more
than one filename per line, depending upon the length of the
longest name and the width of the display screen. Filenames are
sorted vertically.
-m The same as -C, for compatibility with previous versions of ls.
-1 Force single (one) column output.
-n Sort the output by name (default), in alphabetic order.
-t Sort the output by date and time, from newest to oldest.
-z Sort the output by filesize, from smallest to largest.
-r Reverse the order of the sort.
-o Don't sort: display filenames in the order in which they occur
in each directory.
-g List each set of matching files as a group in the order that
their fspecs are specified. In other words, if '*.h *.c' are
entered, then the g flag causes all .h files to be displayed
first and all .c files to be displayed next, etc.
The g flag causes the program to make a separate pass through a
directory for each fspec, making 'ls' run slower. The default
behavior is to display all matching files as they are found,
making only one pass through each directory.
-L List filenames in lowercase.
-U List filenames in uppercase. The default is to display DOS FAT
filesystem names names in lowercase and HPFS filesystem names
unchanged.
You can mix and match the f, s, h, and d flags to include as many
different file types as you wish. If you specify at least one of the s,
h, or d flags, then you must explicitly specify the f flag to include
ordinary files in the listing. If you don't specify one of the f, s, h,
d, or a flags, then the default is fd: list only ordinary files and
directories.
You can specify the l (letter el) flag to list file and/or directory
names in "long" format. In this format, each name appears along with its
mode, size, date, and time. The mode (attribute) consists of a set of
characters that are interpreted as follows:
The first character is:
d The name is a directory.
v The file represents a volume id (DOS only).
- The name is a file.
The second character is:
r The file is readable (always!).
- The file is not readable (never!).
The third character is:
w The file is writable.
- The file is readonly.
The fourth character is:
s The file is a system file.
- The file is not a system file.
The fifth character is:
h The file is a hidden file.
- The file is not a hidden file.
The sixth character is:
a The file has been changed (its archive bit is set).
- The file's archive bit is not set.
========================================================================
NOTES
========================================================================
An ordinary file is a directory entry whose 'directory', 'system'
'hidden', and 'volid' attribute (mode) bits are all zero.
Filenames are listed on standard output. Filespecs that don't match
any files are listed on standard error.
A file specification consists of an optional drive, optional path
information, and a filename. The filename may consist of AIX shell
pattern-matching characters. DOS's filename pattern matching is
simplistic, Win32's and OS/2's is a lot better, but Bourne shell pattern
matching is better still. Also, all versions (DOS, Win32, and OS2) of
the commands in this package support the same level of pattern-matching.
A dot within a filename is treated as just another character and not
assumed to be the beginning of a file extension. Indeed, the ls command
has no concept of a file extension. This is compatible with the use of
dots within Win32, NTFS, HPFS, and AIX filenames.
Flag characters are case sensitive, just as in AIX. Name comparisons are
case-insensitive, as specified by DOS, Win32, and OS/2.
If the -l (long format) flag is listed, each file's modification time
and date are displayed. Specify the c flag along with -l to display each
file's time of creation. Or, specify the u flag along with -l to display
each file's time of last access. Note that the c and u flags don't yield
valid times for a file system (such as DOS or OS/2 FAT) that don't
maintain them. Also note that the DOS version simply shows the time of
last modification for the -lu and -lc flags.
You may specify more than one set of flags. For example, you may enter
the commands 'ls -n -l *.c *.h' and 'ls -nl *.c *.h' both list all .c
and .h files in long format, sorted by name.
The order in which you specify certain flags is important. For example,
if you specify the -l, -m, and/or -1, the last one entered takes
precedence. Likewise, if you specify -o, -n, -z, and/or -t, the last one
entered overrides the others.
If the ls command is displaying filenames in multicolumn format and/or
sorting the names, then ls first stores all of the filenames in memory,
sorts them (n, t, or z flag), and determines how many columns to
display. The DOS version of the ls command may run out of memory for
large file listings. If it does, you should re-run ls with the -1o
(number 1 and letter o) flags: force single-column output and don't
sort.
For DOS, filenames are listed by default in lowercase since this is more
readable (especially on smaller displays). For OS/2, HPFS, NFS, and
TVFS, all filenames are displayed as-is. For Win32, all filenames are
displayed as-is. If you want uppercase filenames (such as DOS DIR and
OS/2 GSEE provide), then specify the -U flag. For OS/2 and Win32, the -L
flag will force all names to be shown in lowercase.
The Watcom-built versions (Win32, OS/2, and DOS) cannot list the volume
label. The DOS version does not support the -u and -c flags.
Enter 'ls -?' to get help.
========================================================================
EXAMPLES
========================================================================
ls * These commands all mean the same thing: List all
ls ordinary files and subdirectories within the current
ls -fd * directory. They match the same files that the DOS
command 'dir *.*' matches.
ls *.* This command lists all ordinary files in the current
directory that have an extension (that is, that have a
dot in their file name). This is not the same as the
'ls *' command nor is it the same as the 'dir *.*'
command, since it won't list any files or directories
whose name contains no dot.
ls -Cn List all files in the current directory in multi-column
format, sorted by name. This is the default behaviour
for the ls command when stdout is the display (and when
ls is entered with no flags or arguments).
ls *.c List all files in the current directory that end in .c
(or have the .c extension, in DOS's words).
ls *.c *.h List all files in the current directory that end in
either '.c' or '.h'. Notice that you can enter more
than one file specification.
ls -a a: List all files and subdirectories in the current
directory of the A: drive.
ls -lsh * This command lists only hidden and system files in the
current directory, along with their mode (attributes),
sizes, and time and date stamps.
ls -d * This command lists all subdirectories within the
current directory. The DOS 'DIR *.' command sort of
does the same thing, provided that directory names have
no extension and file names always have an extension.
ls -l List each file in the current directory, along with its
mode, size, and time and date of last modification.
ls -lc Like -l, except display each file's time and date of
creation. (Win32 and OS/2 versions only.)
ls -lu Like -l, except display each file's time and date of
last access. (NTFS and HPFS only.)
ls -Rd c:\ List all directories and subdirectories on drive C,
starting at the root directory. This produces a tree
listing of drive C.
ls -R c:\[a-m]*.exe
List all .exe files on drive C that begin with the
letters A through M, inclusive.
ls -R c:\my.bat List all occurances of the my.bat file on drive C.
This command performs a "whereis" type of function.
ls -R *.c List all .c files in the current directory and,
recursively, in any subdirectories within the current
directory.
ls -lRdn \ List all directories on the current drive in "long"
format, sorted by directory name.
ls -lt List all files in the current directory in "long"
format, sorted by date and time of modification.
ls -lut List all files in the current directory in "long"
format, sorted by date and time of last access. (OS/2
version only.)
ls -luo List all files in the current directory in "long"
format, in the order in which they occur in the
directory (unsorted). Display the time of last access
for each one.
ls -lRn You may specify flags in one or more groups. For
ls -l -Rn example, these commands all produce identical results.
ls -l -R -n
ls -lC1 The same command as 'ls -1'. The m flag disables the l
flag, and the 1 flag in turn disables the C flag.