*** Special ksh Commands The following simple commands are executed in the shell process. Input/output redirection is permitted. Unless otherwise indicated, the output is written on file descriptor 1 and the exit status, when there is no syntax error, is 0 (zero). Commands that are indicated as command1 or command2 are treated specially in the following ways: o+ Parameter assignment lists that precede the command remain in effect when the command completes. o+ I/O redirections are processed after parameter assignments. o+ Errors cause a script that contains the commands so marked to abort. o+ Words, following a command specified as command2 that are in the for- mat of a parameter assignment, are expanded with the same rules as a parameter assignment. This means that ~ (tilde) substitution is per- formed after the = (equal sign). Word splitting and filename genera- tion are not performed. :[argument ...]1 The command only expands arguments. . file [argument ...]1 Reads the complete file and executes the commands. The commands are executed in the current shell environment. The search path specified by PATH is used to find the directory containing file. If any argu- ments are specified, they become the positional parameters. Otherwise, the positional parameters are unchanged. The exit status is the exit status of the last command executed. alias [-tx] [name[=value ...]]2 The alias command with no arguments prints the list of aliases in the form name=value on standard output. An alias is defined for each name whose value is given. A trailing space in value causes the next word to be checked for alias substitution. The -t flag is used to set and list tracked aliases. The value of a tracked alias is the full path- name corresponding to the given name. The value becomes undefined when the value of PATH is reset but the aliases remained tracked. Without the -t flag, for each name in the argument list for which no value is given, the name and value of the alias is printed. The -x flag is used to set or print exported aliases. An exported alias is defined for scripts invoked by name. The exit status is nonzero if a name is given without a value, and no alias was defined. bg [job ...] Puts each specified job into the background. The current job is put into the background if job is not specified. (See Jobs for a descrip- tion of the format of job.) break [n]1 Exits from the enclosing for, while, until, or select loop, if any. If n is specified, breaks n levels. continue [n]1 Resumes the next iteration of the enclosing for, while, until, or select loop. If n is specified, resumes at the nth enclosing loop. cd [argument] cd old new This command can be in either of two forms. In the first form, it changes the current directory to argument. If argument is a - (dash), the directory is changed to the previous directory. The HOME shell parameter is the default argument. The PWD parameter is set to the current directory. The CDPATH shell parameter defines the search path for the directory containing argument. Alternative directory names are separated by a : (colon). The default path is a null string, specify- ing the current directory. Note that the current directory is specified by a null pathname, which can appear immediately after the = (equal sign) or between the colon delimiters anywhere else in the path list. If argument begins with a / (slash), the search path is not used. Oth- erwise, each directory in the path is searched for argument. The second form of cd substitutes the string new for the string old in the current directory name PWD and tries to change to this new directory. The cd command cannot be executed by rsh. echo [argument ...] Writes arguments to standard output. eval [argument ...]1 The arguments are read as input to the shell and the resulting commands are executed. exec [argument ...]1 If argument is given, the command specified by the arguments is exe- cuted in place of this shell without creating a new process. Input/output arguments can appear and affect the current process. If no arguments are given, the effect of this command is to modify file descriptors as prescribed by the input/output redirection list. In this case, any file descriptor numbers greater than 2 that are opened with this mechanism are closed when invoking another program. exit [n]1 Causes the shell to exit with the exit status specified by n. If n is omitted, the exit status is that of the last command executed. An End-of-File also causes the shell to exit, except for a shell which has the ignoreeof option (see set) turned on. export [name[=value ...]]2 export -p The given names are marked for automatic export to the environment of subsequently executed commands. The export -p command outputs the names and values of all exported variables, one per line, in the format export variable=value fc [-r] [-e editor] [first [last]] fc -l [-nr] [first [last]] fc -s [old=new] [command ] In the first two forms, a range of commands from first to last is selected from the last HISTSIZE commands that were entered at the ter- minal. The arguments first and last can be specified as a number or as a string. A string is used to locate the most recent command that starts with the given string. A negative number is used as an offset to the current command number. In the first form the editor program editor is invoked on a file con- taining these keyboard commands. In the second form, the commands are listed on standard output and no editor is invoked. In the first form, if editor is not supplied, the value of the parame- ter FCEDIT (default /usr/bin/ed) is used as the editor. When editing is complete, the edited commands are executed. If last is not speci- fied, then it is set to first. If first is not specified, the default is the previous command for editing and -16 for listing. The -r flag reverses the order of the commands and the -n flag suppresses command numbers when listing. In the third form, command is reexecuted, without invoking the editor, after the optional substitution old=new is performed. fg [job ...] Each job specified is brought to the foreground. Otherwise, the current job is brought into the foreground. (See Jobs for a descrip- tion of the format of job.) getopts optstring name [argument ...] Checks argument for legal options. If argument is omitted, the posi- tional parameters are used. An option argument begins with a + (plus sign) or a - (dash). An option not beginning with + or - or the argu- ment -- ends the options. The optstring special command contains the letters that getopts recognizes. If a letter is followed by a : (colon), that option is expected to have an argument. The options can be separated from the argument by spaces. The getopts special command places the next option letter it finds inside variable name each time it is invoked with a + prepended when argument begins with a +. The index of the next argument is stored in OPTIND. The option argument, if any, gets stored in OPTARG. A leading : in optstring causes getopts to store the letter of an invalid option in OPTARG, and to set name to a ? (question mark) for an unknown option and to : when a required option is missing. Otherwise, getopts prints an error message. The exit status is nonzero when there are no more options. hash [-r] Without the flag, equivalent to alias -t. The -r flag empties the list of tracked aliases. inlib library_name This command is no longer supported. See the loader(5) reference page for information on using shared libraries. jobs [-lnp] [job ...] Lists information about each given job; or all active jobs if job is omitted. The -l flag lists process IDs in addition to the normal information. The -n flag only displays jobs that have stopped or exited since last notified. The -p flag causes only the process group to be listed. (See Jobs for a description of the format of job.) kill [-signal] job ... kill -l Sends either the TERM signal or the specified signal to the specified jobs or processes. Signals are either given by number or by names (as given in /usr/include/signal.h, stripped of the prefix SIG). If the signal being sent is TERM (terminate) or HUP (hangup), the job or pro- cess is sent a CONT (continue) signal if it is stopped. The argument job can be the process ID of a process that is not a member of one of the active jobs. (See Jobs for a description of the format of job.) In the second form, kill -l, the signal numbers and names are listed. let argument ... Each argument is a separate arithmetic expression to be evaluated. (See Arithmetic Evaluation for a description of arithmetic expression evaluation.) The exit status is 0 (zero) if the value of the last expression is nonzero, and 1 otherwise. newgrp [-] [group] Changes the primary group identification of the current shell process to group. If you specify a - (dash), newgrp changes the login environ- ment to the login environment of the new group. If you do not specify a group, newgrp changes the group identification to that specified for the current user in the /etc/passwd file. The newgrp command recog- nizes group names only; it does not recognize group ID numbers. Only a user with superuser authority can change the primary group of the shell to one to which that user does not belong. Any active user-generated shell is terminated when the newgrp command is used. print [-Rnprsu[n]] [argument ...] The shell output mechanism. With no flags or with flag - or --, the arguments are printed on standard output as described by echo. In raw mode, -R or -r, the escape conventions of echo are ignored. The -R option prints all subsequent arguments and options other than -n. The -p option causes the arguments to be written onto the pipe of the process spawned with |& instead of standard output. The -s option causes the arguments to be written onto the history file instead of standard output. The -u flag can be used to specify a 1-digit file descriptor unit number n on which the output is placed. The default is 1. If the -n flag is used, no newline is added to the output. pwd Equivalent to print -r - $PWD. read [-prsu[n]] [name?prompt] [name ...] The shell input mechanism. One line is read and is broken up into fields using the characters in IFS as separators. In raw mode, a \ (backslash) at the end of a line does not signify line continuation. The first field is assigned to the first name, the second field to the second name, and so on, with leftover fields assigned to the last name. The -p flag causes the input line to be taken from the input pipe of a process spawned by the shell using |&. If the -s flag is present, the input is saved as a command in the history file. The -u flag can be used to specify a 1-digit file descriptor unit to read from. The file descriptor can be opened with the exec special command. The default value of n is 0 (zero). If name is omitted, REPLY is used as the default name. The exit status is 0 (zero) unless an End-of-File is encountered. An End-of-File with the -p flag causes cleanup for this process so that another can be spawned. If the first argument contains a ? (question mark), the remainder of this word is used as a prompt on standard error when the shell is interactive. The exit status is 0 (zero) unless an End-of-File is encountered. readonly [name[=value ...]]2 readonly -p The variables whose names are given are marked read-only. These vari- ables can not be unset or changed by subsequent assignment. The -p flag outputs the names and values of all readonly variables, one per line, in the format readonly variable=value return [n]1 Causes a shell function to return to the invoking script with the return status specified by n. If n is omitted, the return status is that of the last command executed. If return is invoked while not in a function or a . (dot) script, it is the same as an exit. rmlib library_name This command is no longer supported. See the loader(5) reference page for information on using shared libraries. set [+ | -abCefhkmnopstuvx] [+ | -o option ...] \ [+ | -A name] [argument ...] Using + rather than - causes these flags to be turned off. These flags can also be used upon invocation of the shell. The flags for the set command have the following meanings: -A name Array assignment. Unsets the variable name and assign values sequentially from the list argument. If +A is used, the variable name is not unset first. -a Automatically exports subsequent parameters that are defined. -b Causes the shell to notify the user asynchronously of background job completions. -C Prevent existing files from being overwritten by the shell's > redirection operator; the >| redirection operator overrides this noclobber option for an individual file. -e If a command has a nonzero exit status, executes the ERR trap, if set, and exits. This mode is disabled while reading profiles. -f Disables filename generation. -h Each command becomes a tracked alias when first encountered. -k All parameter assignment arguments are placed in the environment for a command, not just those that precede the command name. -m Background jobs will run in a separate process group and a line will print upon completion. The exit status of background jobs is reported in a completion message. On systems with job control, this flag is turned on automatically for interactive shells. -n Reads commands and checks them for syntax errors, but does not exe- cute them. Ignored for interactive shells. -o The argument can be one of the following option names: allexport Same as a. errexit Same as e. bgnice Runs all background jobs at a lower priority. This is the default mode. emacs Invokes an emacs style inline editor for command entry. gmacs Invokes a gmacs-style inline editor for command entry. ignoreeof The shell does not exit on End-of-File. The exit command must be used. keyword Same as k. markdirs All directory names resulting from filename generation have a trailing / (slash) appended. monitor Same as m. noclobber Prevents redirection > from truncating existing files. Requires >| to truncate a file when turned on. noexec Same as n. noglob Same as f. nolog Does not save function definitions in history file. nounset Same as u. privileged Same as p. verbose Same as v. trackall Same as h. vi Invokes, in insert mode, a vi-style inline editor until you press Escape (ASCII 033). This changes to move mode. A return sends the line. viraw Each character is processed as it is entered in vi mode. xtrace Same as x. If no option name is supplied, then the current option settings are printed. -p Disables processing of the $HOME/.profile file and uses the /etc/suid_profile file instead of the ENV file. This mode is on whenever the effective user ID or group ID is not equal to the real user ID or group ID. Turning this off causes the effective user ID and group ID to be set to the real user ID and group ID. -s Sorts the positional parameters. -t Exits after reading and executing one command. -u Treats unset parameters as an error when substituting. -v Prints shell input lines as they are read. -x Prints commands and their arguments as they are executed. - Unsets x and v flags and stops examining arguments for flags. -- Does not change any of the flags; useful in setting $1 to a value beginning with -. If no arguments follow this flag, the positional parameters are unset. These flags can also be used upon invocation of the shell. The current set of flags can be found in $-. Unless -A is specified, the remaining arguments are positional parameters and are assigned, in order, to $1 $2 .... If no arguments are given, the names and values of all named parameters are printed on the standard output. If the only argument is +, the names of all named parameters are printed. shift [n]1 The positional parameters from $n+1 ... are renamed $1 ...; the default n is 1. The argument n can be any arithmetic expression that evaluates to a nonnegative number less than or equal to $#. times1 Prints the accumulated user and system times for the shell and for processes run from the shell. trap [argument] [signal ...]1 The argument variable specifies a command to be read and executed when the shell receives the specified signals. (Note that argument is scanned once when the trap is set and once when the trap is taken.) Each signal can be given as a number or as the name of the signal. Trap commands are executed in order of signal number. Any attempt to set a trap on a signal that was ignored on entry to the current shell is ineffective. If argument is omitted or is -, all traps signal are reset to their original values. If argument is the null string, this signal is ignored by the shell and by the commands it invokes. If signal is ERR, argument is executed whenever a command has a nonzero exit status. If signal is DEBUG, argument is executed after each command. If signal is 0 or EXIT and the trap statement is executed inside the body of a func- tion, the command argument is executed after the function completes. If signal is 0 (zero) or EXIT for a trap set outside any function, the command argument is executed on exit from the shell. The trap command with no arguments prints a list of commands associated with each signal number. typeset [+ | -HLRZfilrtux[n]] [name[=value ...]]2 Sets attributes and values for shell parameters. When invoked inside a function, a new instance of the parameter name is created. The parame- ter value and type are restored when the function completes. The fol- lowing list of attributes can be specified: -f The names refer to function names rather than parameter names. No assignments can be made and the only other valid flags are -t, -u, and -x. The -t flag turns on execution tracing for this function. The -u flag causes this function to be marked undefined. The FPATH variable is searched to find the function definition when the func- tion is referenced. The -x flag allows the function definition to remain in effect across shell procedures invoked by name. -H Provides system-to-hostname file mapping on machines that restrict the set of characters in filenames. -i Parameter is an integer. This makes arithmetic faster. If n is nonzero, it defines the output arithmetic base; otherwise, the first assignment determines the output base. -l All uppercase characters are converted to lowercase. The uppercase -u flag is turned off. -L Left justifies and removes leading spaces from value. If n is nonzero, it defines the width of the field; otherwise, it is deter- mined by the width of the value of first assignment. When the parameter is assigned, it is filled on the right with spaces or truncated, if necessary, to fit into the field. Leading zeros are removed if the -Z flag is also set. The -R flag is turned off. -r The given names are marked read-only and these names cannot be changed by subsequent assignment. -R Right justifies and fills with leading spaces. If n is nonzero, it defines the width of the field; otherwise, it is determined by the width of the value of first assignment. The field is left-filled with spaces or truncated from the end if the parameter is reas- signed. The L flag is turned off. -t Tags the named parameters. Tags are user definable and have no special meaning to the shell. -u All lowercase characters are converted to uppercase characters. The lowercase -l flag is turned off. -x The given names are marked for export. -Z Right justifies and fills with leading zeros if the first nonspace character is a digit and the -L flag was not set. If n is nonzero, it defines the width of the field; otherwise, it is determined by the width of the value of first assignment. Using + (plus sign) rather than - (dash) causes these flags to be turned off. If no name arguments are given but flags are specified, a list of names (and optionally the values) of the parameters that have these flags set is printed. (Using + rather than - keeps the values from being printed.) If no names and flags are given, the names and attributes of all parameters are printed. ulimit [-HSacdfmnstvw] [limit] Sets or displays a resource limit. Available resources limits follow. Many systems do not contain one or more of these limits. The limit for a specified resource is set when limit is specified. The value of limit can be a number in the unit specified with each resource, or the value unlimited. The H and S flags specify whether the hard limit or the soft limit for the given resource is set. A hard limit cannot be increased once it is set. A soft limit can be increased up to the value of the hard limit. If neither H nor S is specified, the limit applies to both. The current resource limit is printed when limit is omitted. In this case, the soft limit is printed unless H is specified. When more than one resource is specified, the limit name and unit are printed before the value. -a Lists all of the current resource limits. -c The number of 512-byte blocks on the size of core dumps. -d The number of Kilobytes on the size of the data area. -f The number of 512-byte blocks on files written by child processes (files of any size can be read). -m The number of Kilobytes on the size of physical memory. -n The number of file descriptors. -s The number of Kilobytes on the size of the stack area. -t The number of seconds to be used by each process. -v The number of Kilobytes for virtual memory. Note: This option is supported only if RLIMIT_VMEM has been defined in /usr/include/sys/resource.h. -w The number of Kilobytes for the swap area. Note: This option is supported only if RLIMIT_SWAP has been defined in /usr/include/sys/resource.h. If no option is given, -f is assumed. umask [-S] [mask] The user file-creation mask is set to mask (See umask.) mask can either be an octal number or a symbolic value as described in chmod. If a symbolic value is given, the new umask value is the complement of the result of applying mask to the complement of the previous umask value. If mask is omitted, the current value of the mask is printed. -S Produces Symbolic output unalias name ... unalias -a The parameters given by the list of names are removed from the alias list. The unalias -a command removes all aliases from the current shell execution environment. unset [-fv] name ... The variables or functions given by the list of names are unassigned, that is, their values and attributes are erased. Read-only variables cannot be unset. If the -f flag is specified, the names refer to func- tion names. If no flags or the -v flag is specified, the names refer to variables. Unsetting ERRNO, LINENO, MAILCHECK, OPTARG, OPTIND, RAN- DOM, SECONDS, TMOUT, and _ removes their special meaning even if they are subsequently assigned. wait [job] Waits for the specified job and reports its termination status. If job is not given, all currently active child processes are waited for. The exit status from this command is that of the process waited for. (See Jobs for a description of the format of job.) whence [-pv] name ... For each name, indicates how it would be interpreted if used as a com- mand name. The -v flag produces a more verbose report. The -p flag does a path search for name even if name is an alias, a function, or a reserved word.