home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.update.uu.se
/
ftp.update.uu.se.2014.03.zip
/
ftp.update.uu.se
/
pub
/
rainbow
/
msdos
/
misc
/
unixutil.lzh
/
UNXUTIL.DOC
< prev
next >
Wrap
Text File
|
1985-06-26
|
29KB
|
1,255 lines
- 1 -
----------------------------------------------------------------
NOTES
----------------------------------------------------------------
NEW UTILITIES FOR THE OPERATING SYSTEM DISKS
FOR MS-DOS 2.0
SEARCH - uses powerful search rules to: give directory
listings, copy files, archive files, modify file
attributes, sum file sizes, and delete files.
Additional options allow you to request prompting,
recursively traverse sub-directories, and copy
entire tree structures.
WC - prints the number of lines and words in each of a
list of files.
FGREP - searches through a list of files for files which
contain a specific text string. The line which
contains the text string and the file's name are
output. Options allow searching sub-directories,
listing only file names, and listing a count of
the number of lines which match.
MV - move a file or list of files. This can copy files
from one directory to another, perform a rename
function, or copy a file to another volume
(removing the original).
TAIL - prints the last 'n' lines of a file or list of
files.
CAT - concatenates a list of files and outputs them.
LIST - produces a directory listing (in various formats)
of a file or list of files.
SEARCH UNIX like Utilities for MS-DOS 2.0 Page- 1
SEARCH ---
The SEARCH utility is used to search, possibly traversing any
subdirectories and match your specified files. Once files are
matched, their directory entry may be output, they may be copied,
their attributes may be changed, or they may be deleted. The
basic format of the SEARCH command is:
SEARCH <ms-dos file or directory names> <matching constraints>
<actions>
The <ms-dos file or directory names> is a list of one or more
directory and/or file names (which can include MS-DOS wildcards).
This list specifies the possible domain on which the SEARCH
command will operate. For example, if you specify:
SEARCH a:/ b:/ c:/ <other parameters>
the SEARCH utility will search starting in the root directories
on drives a:, b:, and c: (and only on those drives). As another
example,
SEARCH rtc.asm rtc.src tod.asm <other parameters>
the SEARCH utility will consider only the three files specified
when executing the other parameters. Note that file names and
directories may be intermixed (allowing you to specify a domain
of some directories, some specific files, etc.).
The second set of parameters to SEARCH, <matching constraints>
further define which particular files in the domain of files
and/or directories specified you are interested in. These
options are each permitted, but each option is only permitted
once in the command line. In order for a file to be acted upon,
it must meet all conditions specified in <matching constraints>.
-name <names> to perform further pattern matching on the
names of the files specified, or the files
found in the directories specified. <names>
may be one or more file names. The syntax
for multiple file name is file names
separated by exclamation marks (eg, rtc.asm !
tod.asm | tod.obj).
These file names may have an extended type of
SEARCH UNIX like Utilities for MS-DOS 2.0 Page- 2
wild-card specification. The standard MS-DOS
? wild-card function is supported.
In addition * is supported and operates
anywhere in the text (for example, in MS-DOS
*a* is equivalent to *, the first * pads out
to the end of the name; using *a* in this
syntax matches anything with an 'a' in it).
Extra switches have been designed to general
ize pattern matching. By using the '-.'
switch, wild-cards will also match the '.'
between the file name and extension (for
example, in MS-DOS *.* must be specified to
match all files; using * with the '-.' switch
accomplishes the same thing). By using the
'-/' switch, wild-cards will also match the
'/' in a pathname (for example, in MS-DOS
a/*/*.pas would match a/x/y.pas and a/z/w.pas
but not a/x/y/z/q/r/x.pas; using the * with
the '-/' switch would also match the final
path.
A final type of wild-card is a 'multiple-
choice' selection, by specifying characters
in brackets, the ? wild-card function can be
constrained to only certain characters (for
example, [aeiou]*.asm will match any filename
beginning with a vowel and having an
extension of 'asm.'
Examples of wild cards for -name:
[bv][tc][1k]FD*.*
would match any file with B or V as
its first character, T or C as its second, 1
or K as its third, and FD as its fourth and
fifth
[bx][tc][1k]FD* -.
uses the switch to match the '.'
between the name and extension, and is
equivalent to the above example
*OMF.BAS
will match any file whose name ends
with OMF and extension is BAS
SEARCH UNIX like Utilities for MS-DOS 2.0 Page- 3
???BASE.??
will match any file whose name has
BASE as its 4th to 7th characters and has a 2
character extension
-^name <names> the files found must NOT match any of the
names specified. See -name, above for a
description of what the <names> can be.
Examples:
-^names *.asm
will match any file which does not have
the extension 'asm.'
-^names [bv]*.*
will match any file whose name does not
begin with a B or V.
-name *.asm -^name BT1*.*
using both specifications, the combined
patterns will match any file with an
extension of 'asm' whose name does not begin
with BT1.
-fname <names> the full path name must not match any of the
names specified. See -name, above, for a
description of what the <names> can be. The
difference between -fname and -name is that
the -name constraint only performs the
matching test on the file's name, while the
-fname will perform its test against the full
pathname for that file (from the root
directory). For example,
-name a*
would match any file name beginning with
SRC. This is also true if -/ is added.
-fname a* -/
would match any pathnamme beginning with
A, that is, all files on the A: drive. If
patterns are specified to made drive
designagors, remember that the format is d:/,
example:
-fname a:/t* -/ -. (matches any file
SEARCH UNIX like Utilities for MS-DOS 2.0 Page- 4
beginning with the letter T in the A: drive's
root directory, or any subdirectory of A:'s
root directory whose name begins with a T).
-^fname <names> the full path names found must not match any
of the names specified in <names>. Refer to
-names, -^names, and -fnames for details.
For example,
-^fname a:/temp/* -/
will not match any of the files in drive
A:'s subdirectory temp.
-LE <filename> the found file's time of creation (date and
time) must precede or be the same as
"filename"s time. (Read "LE" as "less-than-
or-equal-to".)
-LT <filename> the found file's time of creation (date and
time) must precede "filename"s time. (Read
"LT" as "less-than".)
-GE <filename> the found file's time of creation (date and
time) must follow or be the same as
"filename"s time. (Read "GE" as "greater-
than-or-equal-to".)
-GT <filename> the found file's time of creation (date and
time) must follow "filename"s time. (Read
"GT" as "greater-than".)
The next four constraints offer the same
functionality as the LE, LT, GE, and GT
options, except only on a date basis. The
preceding four constraints use both date and
time (the date is really part of the time
"continuum".)
-LEDATE <filename> the found file's date must precede or be the
same as "filename"s date. (Read "LE" as
"less-than-or-equal-to".)
SEARCH UNIX like Utilities for MS-DOS 2.0 Page- 5
-LTDATE <filename> the found file's date must precede
"filename"s date. (Read "LT" as "less-
than".)
-GEDATE <filename> the found file's date must follow or be the
same as "filename"s date. (Read "GE" as
"greater-than-or-equal-to".)
-GTDATE <filename> the found file's date must follow "filename"s
date. (Read "GT" as "greater-than".)
Note: using search with -GE (or -GEDATE) and
-LE (or -LEDATE) will match only those files
with exactly the same creation time (or
date).
-exists <pathname> the file found will match this if a file of
that same name is also present at the path
specified. The path is computed as explained
in -comp, below.
-^exists <pathname> the file found will match this only if there
is not a file of that same name present at
the path specified. The path is computed as
explained in -comp, below.
-size <bytes> the file found will match this only if it is
at least the number of bytes specified in
size.
-sizeb <blocks> the file found will match this only if it is
at least the number of (512-byte) blocks
specified in size.
-attr <attr exp> the file found will match this if it's
attributes make the attribute expression
specified true. The expression consists of
ANDs, ORs, NOTs, and letters which represent
attributes. Use & for AND, ! for OR, ^ for
SEARCH UNIX like Utilities for MS-DOS 2.0 Page- 6
unary NOT, parentheses for grouping sub-
expressions, and the following attribute
letters:
a for the archive bit being on
d for the directory bit being on
h for the file being hidden
r for the file being read-only
s the for file being a system file
For example:
-attr a&^r
would match any file whose archive bit
is on (has been changed since the last
archive) which is not read-only (can ever be
changed).
-comp <pathname> the file found will match this pattern if
there is a file of the same name as the file
found in the specified path AND the two files
are equivalent. Any differences between the
two files are displayed.
The -t switch preserves directory tree
structure. If SEARCH A: -COMP Z found a:/x/y,
the file a:/x/y would be compared to a:/x/z/y
instead of a:/z/y. The target pathname for
the compare is computed as follows:
1. The drive prefix, and any ./ or ../
prefixes are deleted from the pathname of the
file found.
2. The remainder of the pathname (up to the
filename) is appended to the destination path
after the -COMP to produce the file which is
to be compared.
-^comp <pathname> the file found will match this pattern if
there is not a file of the same name as the
file found in the specified path OR the two
files are not equivalent. Any differences
between the two files are displayed. See -
COMP, above.
SEARCH UNIX like Utilities for MS-DOS 2.0 Page- 7
The third set of parameters to SEARCH are the <actions>s. These
options specify what function is to be performed on the files
which match the constraints specified. Actions allow setting and
resetting of file attributes; moving, copying, deleting, and
backing up files; printing directory entries; and summing files'
sizes.
The following are the switch settings for actions. Any action
marked with an asterisk may be specified at most once.
-attr+ <attrs> turns on the specified attributes. Specify
<attrs> as single-character attributes, as
above. For example,
-attr+ ar
would set the archive and read-only
bits.
-attr- <attrs> turns off the specified attributes. See
above for details.
-mv <pathname> * moves the files found into the specified
pathname. If the -t option is specified, the
tree structure of the source file is
preserved. For example, if SEARCH A: finds
a:/x/y, and -MV Z were specified, z/x/y would
be created, rather than z/y. The destination
pathname is formed from the source pathname
as follows:
1. The drive prefix and any ./ or ../ is
removed from the source pathname.
2. The remainder of the source pathname is
apopended to the destination path after the
specified -mv pathname.
-cp <pathname> * copies the files found into the specified
pathname. The -t option (see above) also
applies. This cannot be used in conjunction
with a -backup option.
SEARCH UNIX like Utilities for MS-DOS 2.0 Page- 8
-backup <pathname> * this is a useful function which is an
abbreviation for
-cp <pathname> -attr a -attr- a
That is, it finds archivable files and resets
the archive bit after the copy. This cannot
be used in conjunction with a -cp option.
-print list the names of the files (this is the
default if no actions are specified).
-rm remove the files found. If -cp is specified,
the copy is performed prior to the removal.
If -mv is specified, the -rm has no effect.
-rmdir remove any empty directories encountered. If
-mv is specified, the directory remove is
attempted after the files have been moved.
This means that
SEARCH x -mv b: -rmdir
effectively moves all of x to the b: disk and
removes all of sub-directory x.
-ls list file directory entries in long format.
This displays attribute settings, file size,
the file's time and date, and its full path
name. If an attribute is not set for a file,
'-' is printed, if it is set, the attribute
is printed. For read-write files, 'w' is
printed instead of the '-'.
-sum a sum of the sizes of files found is
displayed. This is the exact size of the
data in the files and does not consider
allocation units' round-off.
-tarc <filename> * creates a "tape archive" file named
<filename> containing all files found. This
SEARCH UNIX like Utilities for MS-DOS 2.0 Page- 9
is useful for creating one large file to be
used as an archive. The files may be
extracted using the -tarx option below. For
example,
SEARCH *.pas -tarc pasbkup.tar
will put all .PAS files into the file
PASBKUP.TAR.
-tara <filename> * this is the same as -tarc, above, except
that the files found are appended to an
existing "tar" file.
-tarx <filename> * search the files in "tar" file <filename>.
The only action that you can perform with
this option is to -ls, -print, -sum, or -cp
them. -rm or -mv options will be ignored.
For example,
SEARCH -tarx pasbkup.tar -ls
would list the files in the above "tar"
file
SEARCH -tarx pasbkup.tar -cp xyz
would copy the files in the above "tar"
file into directory xyz
Some additional options also exist which effect the above actions
and/or constraints.
-nr no recursive searching of sub-directories.
SEARCH will normall search any directories
you specify and all sub-direcctories (and
their sub-directories . . .). Using this
option limits searches to only directories
specified.
-p prompts (asks yes/no) for -cp, -mv, -rm, or
attribute settings. For any action which
would have a permanent effect, you may use
SEARCH UNIX like Utilities for MS-DOS 2.0 Page- 10
this to verify SEARCH's actions.
-t as explained above, is used to preserve tree
structure of directories for -mv, -cp, -comp,
-exists, -^exists, and -^comp options.
-n take no actions, SEARCH will display what it
would have done, but take no actions. This
is equivalent to using -p and always
responding negatively.
-a short-hand for '-attr a', matching only files
with the archive bit set.
-s be silent (display nothing).
-. allow '.', the file extension separator to be
wild-carded (see above).
-/ allow '/' to be wild-carded (as explained
above).
Single letter options may be grouped after a single '-'
(providing they do not form one of the multiple-letter options).
Multiple-letter options must each have a '-'. For example, you
may specify -avd, but not -nravd.
HINTS
1. SEARCH f: -name *.pas
Does not necessarily SEARCH all files on drive f: with the
extension .PAS . SEARCH will start at the current working
directory for drive f:. To search all of drive f:, either do a
CD / before the above command, or use
SEARCH f:/ -name *.pas
2. To copy all files that have been modified since the last time you
SEARCH UNIX like Utilities for MS-DOS 2.0 Page- 11
did a backup, use
SEARCH <where ever> -backup b:
This copies modified files to your b: drive and resets their
archive bits. If your archive bits are in an unknown state, use
SEARCH <where ever> -attr- a
to reset all archive bits.
3. To find all directories on a drive, use
SEARCH <drive>:/ -attr d
4. Since some commands are short-hand abbreviations, remember
that there are some restrictions. For example,
SEARCH a: -backup b: -attr r
is illegal because '-backup b:' is an abbreviation for '-cp b:
-attr a -attr- a' and only one -attr is allowed. You need to
specify
SEARCH a: -cp b: -attr a&r -attr- a
WC UNIX like Utilities for MS-DOS 2.0 Page- 1
WC ---
The WC utility counts words and lines in a file. Its syntax is:
WC <files or directories> <switches>
The specified files' word/line counts will be output, along with
the total word/line counts. The files used will be all
specified, and all contained in any directories listed. Note
that MS-DOS wild-cards may be used. If no <files or directories>
are specified, then WC accepts keyboard (or redirected) input.
The switches are as follows:
-r to traverse any sub-directories encountered as well.
-w to omit the word counts (this will save time).
Examples:
WC memo.mem
would print the lines and words in the named file
WC *.mem -w
would print the line counts only for all files found, and a
total line count figure.
WC *.mem /documents -w
acts as the example above, but in addition includes all
files in the directory /documents.
WC *.mem /documents -w -r
acts as the example immediately above, but in addition will
include all files in sub-directories of /documents (and sub-
directories of them).
FGREP UNIX like Utilities for MS-DOS 2.0 Page- 1
FGREP ---
The FGREP utility searches files for particular text patterns.
Each line on which the pattern is found is displayed. The text
patterns cannot contain blanks or any wild-cards. The syntax is:
FGREP <options> <pattern> <files or directories>
The values for <options> are as follows:
-r recursively search sub-directories of directories
specified in the list <files or directories>. The
default is to search only files in the <files or
directories> list and files in directories in that
list.
-i ignore upper/lower case when matching the <pattern>.
-l also print line numbers for matching text in files.
-n only print file names of files with matching text.
-v reverse the test--print all lines except those with a
matching text pattern.
-c only print a count of how many lines contain matching
text.
-^ Treat the character ^ in the pattern string as a blank.
Normally, the pattern cannot contain a blank because
command line arguments are separated by blanks. The -^
option is provided so that a blank can effectively be
specified in the pattern. For example,
fgrep -^ a^string *.pas
searches all files ending in .pas for the string "a
string". Without the -^ option, the string "a^string"
would be searched for.
The <pattern> parameter is the text string to search for. This
string is specified exactly as you want it to appear in the
files' lines (that is, it is not surrounded by quotes). The
pattern may contain no blanks, and cannot start with a '-' (which
FGREP UNIX like Utilities for MS-DOS 2.0 Page- 2
is used to specify options).
The <files or directories> parameter is identical to SEARCH, see
above. If no files are given, then FGREP accepts keyboard input
(or redirected input) to search.
Examples:
FGREP -i proc c:/sources d:/project/*.asm
will (ignoring upper/lower case) print a list of files and
their lines which contain the string 'proc', files in the
directory c:/sources, and files with an .ASM extension in the
d:/project directory will be searched.
FGREP -ri proc c:/sources d:/project/*.asm
will act as the above example, except that any sub-
directories of c:/sources (and their sub-directories) will also
participate in the string search.
MV UNIX like Utilities for MS-DOS 2.0 Page- 1
MV ---
The MV command is used to move file(s). The syntax for MV is:
MV <file1> <file2 or directory>
If the second parameter is <file2>, then MV moves file1 into
file2 and deletes file1 (if file1 and file2 are on the same
drive, then file1 is renamed as file2). If the second parameter
is a directory, then file1 is moved into that directory, and the
original file1 is deleted. The first parameter may be an MS-DOS
wild-card specification. In this case, all files matched will be
moved (copied and deleted) into the directory specified.
MV will never move a file onto itself--an error message will
occur and the file will not be deleted. Also, do not MV a wild-
carded file1 onto a file2. In this case, only the first file
will be moved and an error message will occur.
Examples:
MV a:/pmate.exe b:/bin
moves the pmate program to the binary directory of b:
MV *.exe b:/bin
moves all .EXE files to the binary directory of b:
MV memo.mem sept28.mem
renames the file memo.mem as sept28.mem
TAIL UNIX like Utilities for MS-DOS 2.0 Page- 1
TAIL ---
The TAIL utility displays the last n lines of specified files.
The syntax is:
TAIL -<count> <files or directories>
As above, <files or directories> specifies a list of (possibly
wild-carded) files and directories full of files to be operated
upon. The <count> option, if not specified, defaults to 10.
Otherwise you can specify how many of the last lines for each
file to be displayed. The maximum value for <count> is about
450. If a line exceeds 130 characters, TAIL will truncate it.
If no <files or directories> is specified, TAIL will get its
input from the keyboard (or redirected input).
Examples:
TAIL -3 *.lst
will list the last 3 lines of ever file with a .LST
extension in the current directory.
TAIL <input
is equivalent to
TAIL input
and will list the last 10 lines of the file INPUT.
TAIL -50 /temp
will print the last 50 lines of every file in the /temp
directory.
CAT UNIX like Utilities for MS-DOS 2.0 Page- 1
CAT ---
The CAT utility will concatenate the files specified and display
their contents. The syntax is:
CAT <files or directories>
Where <files or directories> is just like it is in the other
utilities. If omitted, input will be taken from the keyboard (or
redirected input). Examples:
CAT *.asm > backup
will take all files with the extension .ASM in the current
directory and (using output redirection) combine them into the
file BACKUP.
CAT /temp
will display the contents of all files in the /TEMP
directory.
CAT /temp *.plm
will display the contents of all files in the /TEMP
directory and all files with the extension .PLM in the current
directory.
LIST UNIX like Utilities for MS-DOS 2.0 Page- 1
LIST ---
The LIST utility lists files in name-only or directory format. The
syntax is:
LIST <options> <files or directories>
The options are:
-l list the directory entries (each file name, the file's
attributes, date, time, and size are listed.
-r recursively list all files in sub-directories of any
directory specified.
-1 list only one file name per line.
-t sort output by file date & time, rather than
alphabetically.
-b sort backwards.
-g list "toGether"; don't separate output on a per-
directory basis.
NOTE: long-format listings will NOT be sorted.
The <files or directories> parameter is as above. If omitted,
the current directory will be used. Examples:
LIST
will list (in short form) the files and directories in the
present directory.
LIST -rl c:/temp *.asm
will list (in long format) the files in the c:/temp
directory (and its sub-directories), and any file with the .ASM
extension in the working directory.