home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 2: PC
/
frozenfish_august_1995.bin
/
bbs
/
d03xx
/
d0342.lha
/
SKsh
/
ExtCmds.doc
< prev
next >
Wrap
Text File
|
1990-04-15
|
31KB
|
1,387 lines
External Command Reference
SKsh
A ksh-like Shell for the Amiga
Version 1.4
(Copyright) 1989, 1990
Steve Koren
March 19, 1990
Table of Contents
Introduction......................................3
cmp...............................................4
cp................................................5
crc...............................................6
du................................................7
fgrep.............................................8
grep..............................................10
head..............................................12
join..............................................13
strings...........................................14
srun..............................................15
tail..............................................16
tee...............................................17
view..............................................18
wc................................................19
window............................................20
xd................................................21
SKsh Amiga Shell Page 2 External Cmd Reference
Introduction
This reference manual describes each SKsh external command in
a concise manner. Each page contains the following
information:
Name: The name of the command.
Type: Always External Command for this document; may be
something else in the reference manual.
Default: Default parameters, if applicable.
Usage: Command syntax
Range: Legal values for variables or parameters
About: Text describing the command, variable, etc.
Example: A brief example usage.
See Also: Other related commands, variables, etc.
When reading the command syntax, anything in square brackets
is optional. Anything followed by three dots can be repeated
any number of times. A vertical bar is used to separate
option where one or the other, but not both, can be used.
In general, 'command -a -b' is equilivant to 'command -ab'.
All external commands were re-written in SKsh 1.4 to be much
smaller and faster than their earlier counterparts.
SKsh Amiga Shell Page 3 External Cmd Reference
________________________________________________________________
Name: cmp
Type: External Command
Default: n/a
Usage: cmp [ -s ] file1 file2
Range: n/a
About: cmp compares two files for equality. It can be
used on binary as well as textual data. cmp is
fast in that if the files are not the same size,
it won't even bother comparing the contents of the
files. cmp normally outputs a message that
indicates whether the files are the same,
different, or one is shorter than the other. If
the -s option is used, compare does not output
this information, but simply returns a zero exit
status if the files were the same, or non-zero if
they were not.
Example: if cmp -s file1 file2
then
echo 'file1 is the same as file2'
else
echo 'file1 is different than file2'
fi
See Also:
________________________________________________________________
SKsh Amiga Shell Page 4 External Cmd Reference
________________________________________________________________
Name: cp
Type: Builtin
Default: n/a
Usage: cp [ -nuv ] file { file | dir }
cp [ -nruv ] { file | dir } ... dir
Range: n/a
About: cp copies files from one place to another,
optionally renaming them in the process. If the
destination is a directory, the files have the
same name in the destination directory. If more
than one file is copied, the destination must be
either a directory or nonexistant. If it is
nonexistant, it is created as a directory.
The -r flag causes cp to perform a recursive copy.
The -v flag prints the name of each file as it is
copied.
The -n flag causes cp NOT to duplicate file
modification times and protection flags on the
destination files. If you wish to make this the
default behavior, use this alias:
alias cp='$(which cp) -n'
cp will reset the AmigaDos archive bit whether or
not the -v flag is used.
The -u flag causes cp to operate in "update" mode;
only files with a newer timestamp than their
associated destination are copied.
Example: cp my_file1 m_file2 my_file3 my_directory
Warnings: The -c (clone) flag was obsoleted in SKsh 1.4. It
is still accepted for backward compatibility;
however, it is ignored. Use the -n option to turn
off the clone behaviour.
The cp command was changed to an external binary
in SKsh 1.4. It used to be a builtin.
See Also: mv
________________________________________________________________
SKsh Amiga Shell Page 5 External Cmd Reference
________________________________________________________________
Name: crc
Type: External Command
Default: n/a
Usage: crc file1 file2
Range: n/a
About: crc generates several 32 bit values which are
computed from a file's contents. These values can
be used to check the integrity of files which are
transfered over a medium of questionable
reliability (such as phone lines).
Example: crc a_file another_file
See Also:
________________________________________________________________
SKsh Amiga Shell Page 6 External Cmd Reference
________________________________________________________________
Name: du
Type: External Command
Default: n/a
Usage: du [ -dkst ] dir ...
Range: n/a
About: du prints disk usage information for a set of
directories. For each directory listed on the
command line, the subtree rooted at that point is
searched in a depth-first manner. du adds all the
file sizes, and for each directory, prints 1) the
directory name, 2) the total disk usage for files
in this directory, and 3) the total disk usage for
the subtree rooted at this directory.
The following options are available:
-k Print disk usage in 1024 byte kilobytes
instead of the default bytes.
-s Summary mode; print disk usage only for
root directories listed on the command
line. This option omits the display for
any sub-directories, but still must
examine the entire directory subtree to
find the total disk usage.
-d Omit the first disk usage number (the
total for this directory only).
-t Omit the second disk usage number (the
total for the subtree rooted at this
directory). If both -t and -d are used,
only directory names are printed.
Example: du devs: ram:
du -s devs:
Warnings: The -k option rounds to the nearest kilobyte. For
example, a 1023 byte file is printed as 1K, and a
511 byte file is printed as 0K. This means that
the rooted subtree disk usage count may not be the
sum of the directory disk usage counts for all
subdirectories.
See Also: info
________________________________________________________________
SKsh Amiga Shell Page 7 External Cmd Reference
________________________________________________________________
Name: fgrep
Type: External Command
Default: n/a
Usage: fgrep -[vxcilns] [-f pfile] [-e] pattern
[ file ... ]
Range: n/a
About: fgrep provides a fast way to search for text
patterns in a set of files. It is similar to,
although more limited but faster than, grep.
fgrep searches for the indicated pattern in the
indicated set of files, if present, or the
standard input, if not. An fgrep pattern is
extremely limited; it can be either a string
constant or a set of string constants separated by
percent signs. For example, these are valid fgrep
statements:
fgrep my_routine *.c
fgrep 'this%or%that' my_file my_other_file
In the second example, fgrep searches for lines
containing any of the three strings.
There are a large number of options availble which
modify the actions of fgrep:
-c Print only a count of matching lines for each
file. If the 'v' option is used with the 'c'
option, a count of non-matching lines is
printed.
-e Use the next argument as the pattern. This
is useful to search for patterns beginning
with a dash.
-f Use the next argument as a file which
contains a newline separated list of values.
This file is read and used in place of the
command line pattern. For example, the
following two examples are equivalent:
fgrep 'foo%bar' myfile
echo "foo" >temp; echo "bar" >>temp
fgrep -f temp myfile
SKsh Amiga Shell Page 8 External Cmd Reference
-i Ignore case in the search. Normally, fgrep
is case sensitive.
-l Print only the names of files which containg
the given pattern. This is fast; if fgrep
finds the pattern anywhere in the file, it
will stop looking and proceed to the next
file. This can save time for large files
where the task is to discover which files
contain the given pattern.
-n Print the line number before each matching
line.
-s Print nothing. Return an exit code of 0
(true) if any file contained the pattern, or
1 (false) if no files contained the pattern.
-v Invert the search. Lines which do not
contain the pattern are printed.
-x Lines must match the pattern exactly, not
simply contain it.
Example: if grep -s my_pattern my_file
then
echo 'my_file contains my_pattern'
fi
Warnings: Patterns which contain '%', spaces, or other
special characters should be quoted to avoid being
interpreted by the shell.
The '%' character is used to separate strings
instead of a newline in Un*x, as there is a
problem in AmigaDos passing parameters containing
newlines to external commands.
See Also: grep
________________________________________________________________
SKsh Amiga Shell Page 9 External Cmd Reference
________________________________________________________________
Name: grep
Type: External Command
Default: n/a
Usage: grep -[vxcilns] [-f pfile] [-e] pattern
[ file ... ]
Range: n/a
About: grep provides a way to search for text patterns in
a set of files. It is similar to, although more
powerful but slower than, fgrep.
grep searches for the indicated pattern in the
indicated set of files, if present, or the
standard input, if not. A grep pattern is a
limited regular expression. An explaination of
regular expressions is beyond the scope of this
document; however, it should be noted that
although they appear similar to wildcards, they
are much different (and more powerful).
There are a large number of options availble which
modify the actions of grep:
-c Print only a count of matching lines for each
file. If the 'v' option is used with the 'c'
option, a count of non-matching lines is
printed.
-e Use the next argument as the pattern. This
is useful to search for patterns beginning
with a dash.
-f Use the next argument as a file which
contains a one-line regular expression.
There can only be one regular expression in
this version of grep, so this option is
currently of limited use. However, if grep
is extended to permit multiple expressions,
the 'f' option will become more useful.
-i Ignore case in the search. Normally, grep is
case sensitive.
-l Print only the names of files which containg
the given pattern. This is fast; if grep
finds the pattern anywhere in the file, it
will stop looking and proceed to the next
file. This can save time for large files
SKsh Amiga Shell Page 10 External Cmd Reference
where the task is to discover which files
contain the given pattern.
-n Print the line number before each matching
line.
-s Print nothing. Return an exit code of 0
(true) if any file contained the regular
expression, or 1 (false) otherwise.
-v Invert the search. Lines which do not
contain the regular expression are printed.
-x The expression must be found at the beginning
of a line.
Example: if grep -s my_pattern my_file
then
echo 'my_file contains my_pattern'
fi
Warnings: Patterns which contain '*', '.', spaces, or other
special characters should be quoted to avoid being
interpreted by the shell.
Be wary of the difference in the 'x' option
between fgrep and grep.
fgrep often more useful than grep because of its
greater speed and smaller size. This is most
noticable on fast devices such as ram or hard
disks.
See Also: fgrep
________________________________________________________________
SKsh Amiga Shell Page 11 External Cmd Reference
________________________________________________________________
Name: head
Type: External Command
Default: num = 10
Usage: head [ -num ] [ file ... ]
Range: 0 <= num
About: head prints the first num lines of each named
file, or the standard input if no files are
indicated. If num is not explicitly set, it has a
default value of 10.
Example: head -5 my_file.c my_other_file.c
See Also: tail
________________________________________________________________
SKsh Amiga Shell Page 12 External Cmd Reference
________________________________________________________________
Name: join
Type: External Command
Default: n/a
Usage: join [ -a ] source1 [ source2 ... ] destination
Range: n/a
About: The join command concatinates binary or ascii data
from multiple files into a single file, optionally
appending the data to the destination file if the
-a flag is set. The destination file is the last
one given.
Example: join file1 file2 dest_file
See Also:
________________________________________________________________
SKsh Amiga Shell Page 13 External Cmd Reference
________________________________________________________________
Name: strings
Type: External Command
Default: num = 6
Usage: strings [ -num ] [ file ... ]
Range: 0 <= num
About: strings searches the named files for strings of at
least num consecutive printable characters. If
found, it prints them. If num is not set, it
defaults to 6.
Example: strings -10 my_file.o binary_file
See Also:
________________________________________________________________
SKsh Amiga Shell Page 14 External Cmd Reference
________________________________________________________________
Name: srun
Type: External Command
Default: stk = 4000
pri = 0
Usage: srun [ -i file ] [ -o file ] [ -s stk ] [ -p pri ]
program [ args ]
Range: 4000 <= stk
-31 <= pri <= 31
About: srun was created to overcome certain deficiencies
in the AmigaDos run command. srun is most useful
in scripts or functions, although it can also be
used from the command line. It allows you to
specify an input file, output file, stack size,
and priority for a command which is run in the
background. Standard input and output cannot be
re-directed with the AmigaDos run command. The
srun command is very useful in functions such as
the one given below (very much simplified from one
given in the Stuff.sksh file).
Example: function zmore {
srun -o pipe:tmp $(which zoo) -print "$1" "$2"
more pipe:tmp
}
See Also: run
________________________________________________________________
SKsh Amiga Shell Page 15 External Cmd Reference
________________________________________________________________
Name: tail
Type: External Command
Default: num = 10, '-' option
Usage: tail [ -num | +num ] [ file ... ]
Range: 0 <= num <= 32000
About: tail prints the last num lines of each named file,
or the standard input if no files are named. If a
'+' precedes num instead of a '-', tail instead
skips num lines and prints the rest of the file.
In SKsh 1.4, the algorithm used by tail was
changed. If run on a file, it will now seek to
the end of the file and read backwards until it
encounters the proper line. This means that
running tail on a large file is now nearly
instantaneous; previously, it would read in the
entire file.
Example: tail -15 my_file.c my_other_file.c
See Also: head
________________________________________________________________
SKsh Amiga Shell Page 16 External Cmd Reference
________________________________________________________________
Name: tee
Type: External Command
Default: n/a
Usage: tee [ -a ] [ file ... ]
Range: less than 32 files
About: tee copies its standard input to its standard
output, and also to any named files. The old
contents of the files are overwritten unless the
append (-a) flag is used. With no arguments, tee
simply copies its input to its output.
Example: fgrep foo my_file | tee save_foo | wc -c
See Also:
_______________________________________________________________
SKsh Amiga Shell Page 17 External Cmd Reference
________________________________________________________________
Name: view
Type: External Command
Default: n/a
Usage: see View.doc
Range: n/a
About: view is a command which allows other commands to
be called based on the type of a given file. See
the View.doc manual for a detail description of
this command.
Example:
See Also:
________________________________________________________________
SKsh Amiga Shell Page 18 External Cmd Reference
________________________________________________________________
Name: wc
Type: External Command
Default: n/a
Usage: wc [ -hcwlqt ] [ file ... ]
Range: n/a
About: wc is a utility which counts characters, words, or
lines in a given series of files (or the standard
input, if no files are indicated). It normally
produces information on all three counts, preceded
by a title for each column. If the c, w, or l
flags are set, only information on characters,
words, or lines is printed. (These can be
combined; for example 'wc -cl'). If the q flag is
set, wc does its work quietly; that is, it leaves
out titles and file names, only reporting the
actual counts. The t flag can be used to obtain a
total at the end, and the h flag prints a helpful
usage message.
Example: if [ $(wc -lq my_file) -lt 10 ]
then
echo "There must be at least 10 lines"
fi
See Also:
________________________________________________________________
SKsh Amiga Shell Page 19 External Cmd Reference
________________________________________________________________
Name: window
Type: External Command
Default: n/a
Usage: window [ -back ] [ -front ] [ -title ]
[ -pos [x,y] ] [ -size [x,y] ] [ -scrsize ]
[ -wmouse ] [ -smouse ]
Range: n/a
About: window is a command which allows parameters of the
current shell window to be modified or examined.
The -back and -front flags cause the window to be
sent to the back or front. The -title flag causes
the current window title to be printed. The -pos
flag with no following parameters can be used to
find the current x and y positions of the window.
With a comma separated set of numbers, it moves
the window to that position if possible.
Similarly, the -size parameter either reports the
size of the current window in pixels, or resizes
the window to that size if possible. The -scrsize
flag reports the current size of the screen
containing this window, and the -smouse and -
wmouse flags report the cursor position relative
to the screen or window.
With no parameters, the window command prints a
helpful usage message. Note that this usage
message contains one additional option which can
be included after the -title flag to change the
window title to a set value. However, this is not
actually permitted by AmigaDos, and although it
works now, it may cause problems, and its use is
not recommended. Use at your own risk.
Example: # move window to back and upper left hand corner
window -back -pos 0,0
See Also:
________________________________________________________________
SKsh Amiga Shell Page 20 External Cmd Reference
________________________________________________________________
Name: xd
Type: External Command
Default: n/a
Usage: xd [ file ... ]
Range: n/a
About: xd (hex dump) prints a hexadecimal dump of each
named file, or the standard input if no files are
named. It prints the hex address of the current
offset as 8 digits, then a hex dump of 16 bytes
separated into groups of 2 bytes, then an ASCII
representation of the 16 bytes, or '.' if the byte
is not a printable character.
Example: xd any_old_file
See Also:
________________________________________________________________
SKsh Amiga Shell Page 21 External Cmd Reference