Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

MT XIA INC.

PUBLICATIONS KORN SHELL 93 – QUICK REFERENCE


KORN SHELL 93 – BUILT-IN COMMANDS Built-in Commands Built-in Commands

Mt Xia publishes information on a variety of topics such as see “conditionals and looping” quick reference -e editor run editor if specified, else run ${FCEDIT}
Business Continuity, Disaster Recovery, High Availability, case -l display on STDOUT
AIX, and Shell Programming. if then else -n don't display line numbers
[...] [[...]] ((...)) -r reverse order
|| && !
Mt Xia Inc. fg [jobid]
113 East Rich continue [n] put jobid in the foreground
Norman, OK 73069 if n not specified, go to next iteration of smallest
getconf [name [pathname]]
enclosing loop. if n is specified, go to next iteration of
display POSIX configuration parameters for name
Dana French, President nth enclosing loop.
and pathname
dfrench@mtxia.com disown [jobid ...]
615.556.0456 getopts [-a name] optstring name [arg ...]
do not send HUP signal to specified jobids when shell
parse command line options and arguments
exits, if none specified use all active jobs.
-a name use name for error and usage messages
Built-in Commands
echo [words]
hist [-e editor] [-lnr] [-N num] [first [last]]
alias [-ptx] [name[=value] ...] send words to STDOUT followed by newline, if no
display shell history from first to last
create an alias; with no arguments, display all aliases words specified, send newline.
-e editor run editor if specified, else run ${FCEDIT}
-p print “alias” before each alias
eval [words] -l display on STDOUT
-t set or print a tracked alias
re-evaluate words using shell processing and execute -n don't display line numbers
-x obsolete: does nothing
result. -N num num is relative to current command
bg [jobid] -r reverse order
exec [-a name] [-c] [words]
put jobid in the background
execute words in place of shell jobs [-lnp] [jobid ...]
break [n] -a use name for argv[0] display job information, if jobid not specified, display
exit from enclosing loop (for, while, until, select), if n is -c clear the environment first all job information
specified, exit from nth enclosing loop if words equal: -l also list process ID's
n>file : open output file using file descriptor n -n list jobs whose status has changed
builtin [-ds] [-f file] [name ...]
n<file : open input file using file descriptor n -p only list process groups
with no arguments, display all built-in commands
n<>file : open input/output file using file descriptor n
-d delete built-in name kill [-n signum] [-s signame] jobid
n<&- : close input file opened on file descriptor n
-f load new built-ins from shared library file send signal identified by signum or signame to jobid.
n>&- : close output file opened on file descriptor n
-s display special built-ins if no signal specified send SIGTERM
n>&m : redirect file descriptor n to file descriptor m
-n signum send signal corresponding to signum
cd [-LP] [dir]
exit [n] -s signame send signal corresponding to signame
if dir not specified, change CWD to $HOME
exit from current shell. If n is not specified use ${?}.
-L use logical path for cd let arg ...
-P use physical path for cd export [-p] [name[=value] ...] evaluate arg as an arithmetic expression. exit value is
- change CWD to $OLDPWD export a shell variable to the environment. if no name 0 if result of expression is non-zero. exit value is 1 if
specified, display all exported variables result of expression is zero.
command [-pvV] name [arg ...]
-p print the word “export” before each variable
if -v or -V not specified, execute name with arg
-p use a default search path, not ${PATH} false looping commands
-v behave like whence performs no action, but has a return value of 1 see “conditionals and looping” quick reference
-V behave like whence -v for (word list)
fc [-e editor] [-lnr] [first [last]]
for (arithmetic)
conditional commands display shell history from first to last
select (menu generator)
Copyright 2006 Mt Xia Inc, All Rights Reserved
MT XIA INC. PUBLICATIONS KORN SHELL 93 – QUICK REFERENCE
Built-in Commands Built-in Commands Built-in Commands
getopts (command line option processing) -u n read from file descriptor n (default=0) -S soft limit type
until (loop until expression is true) name?prompt displays “prompt” and reads input -a display all limits
while (loop while expression is true) into variable identified by name -c core file size (512 byte blocks)
-d kilobytes of data segment
newgrp [word] readonly [-p] [name[=value] ...]
-f maximum file size (512 byte blocks)
change current group to word mark variable names as read-only. Displays list of
-m kilobytes of physical memory
existing read-only variables if names not specified.
print [-f format] [-enprRs] [-u n] [word ...] -n maximum number of file descriptors +1
-p print “readonly” before each variable
display words on STDOUT -p size of pipe buffers (512 byte blocks)
-e evaluate escape sequences (default) return [n] -s kilobytes of stack segment
-f format behave as printf command exit a function with return value of n. if n not specified -t cpu seconds
-n suppress printing newline character at end of line return value is ${?}. If not in function, behaves like -v kilobytes of virtual memory
-p print to STDIN of co-process exit. limit can be result of arithmetic expression
-r suppress evaluation of escape sequences limit can be set to “unlimited” to set it to maximum
set
-R same as -r but also ignore other options
see “set and typeset” quick reference umask [-S] [mask]
-s print to history file
with no arguments, displays the current mask. if
-u n print to file descriptor n (default is 1) shift [n]
mask is specified it is subtracted from default
shifts position of all command line arguments n
printf format [arg ...] permissions of 666 for files, or 777 for directories.
positions to the left. if n not specified, default value of
display output like ANSI C printf, format operators: -S print current mask in symbolic form. symbolic
n is 1
%b expand escape sequences in strings mask is permissions to keep.
%d decimal sleep seconds
unalias [-a] names
%H HTML/XML stop execution for a given number of seconds
remove aliases names
%n put number chars printed into variable
test -a remove all aliases
%P convert regular expression to ksh pattern
evaluates conditional expressions: see “Testing”
%R convert ksh pattern to regular expression unset [-fnv] [names]
quick reference
%q display quoted string that can be re-read unsets variables, name references, or functions
%(fmt)T display date/time in date format fmt times -v unset variables names
%Z evaluates to a null character print accumulated process times -f unset functions names
trap [-p] [word] [sigs] -n unset nameref names
pwd [-LP]
display the name of the current working directory if a signal is received that is in the list of sigs, execute wait [jobid]
(CWD) word. sigs is list of signal numbers or names. wait for job jobid to complete, if jobid not specifed,
-L display logical path (default) if word is null – signal is ignored wait for all child processes to complete.
-P display physical path if word is “-” - default action of signal is performed
whence [-afpv] name ...
if word is non-null – word is executed
read [-A name] [-d delim] [-n count] [-t timeout] indicate how each name is treated by the shell
[-prs] [-u n] [name?prompt] [variables ...] true -a display all interpretations of name
read from STDIN and assign input to variables performs no action, but has a return value of 0 -f skip the search for functions
-A name read words into indexed array name typeset -v display verbose information
-d delim use delim to separate words in input see “set and typeset” quick reference -p do a path search even if name is a keyword,
-n count read at most count bytes alias, or function
-p read from STDOUT of co-process ulimit [type] [options] [limit]
-r do not interpret “\” in input set or display per-process limits. default action is to
-s save input in history file set both hard and soft limits, displays soft limits.
-t timeout wait timeout seconds for input -H hard limit type

Copyright 2006 Mt Xia Inc, All Rights Reserved

You might also like