Special commands are built in to the Korn shell and POSIX shell and executed in the shell process. Unless otherwise indicated, the output is written to file descriptor 1 and the exit status is 0 (zero) if the command does not contain any syntax errors. Input and output redirection is permitted. There are two types of built-in commands, special built-in commands and regular built-in commands.
Refer to the List of Korn Shell or POSIX Shell Built-in Commands for an alphabetical listing of these commands.
Special built-in commands differ from regular built-in commands in the following ways:
In addition, words that are in the form of a parameter assignment following the export, readonly, and typeset special commands are expanded with the same rules as a parameter assignment. This means that tilde substitution is performed after the = (equal sign), and word splitting and file name substitution are not performed.
The Korn Shell provides the following special built-in commands:
: eval newgrp shift . exec readonly times break exit return trap continue export set typeset unset
: [Argument ...] | Expands only arguments. It is used when a command is necessary, as in the then condition of an if command, but nothing is to be done by the command. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
. File [Argument ...] | Reads the complete specified file and then executes the commands. The commands are executed in the current shell environment. The search path specified by the PATH variable is used to find the directory containing the specified file. If any arguments 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. Refer to Parameter Substitution in the Korn Shell or POSIX Shell
for more information on positional parameters.
Note: The .File [Argument ...] command reads the entire file before any commands are carried out. Therefore, the alias and unalias commands in the file do not apply to any functions defined in the file. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
break [n] | Exits from the enclosing for, while, until, or select loop, if one exists. If you specify the n parameter, the command breaks the number of levels specified by the n parameter. The value of n is any integer equal to or greater than 1. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
continue [n] | Resumes the next iteration of the enclosing for, while, until, or select loop. If you specify the n variable, the command resumes at the nth enclosing loop. The value of n is any integer equal to or greater than 1. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
eval [Argument ...] | Reads the specified arguments as input to the shell and executes the resulting command or commands. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
exec [Argument ...] | Executes the command specified by the argument in place of this shell (without creating a new process). Input and output arguments can appear and affect the current process. If you do not specify an argument, the exec command modifies file descriptors as prescribed by the input and 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] | Exits the shell with the exit status specified by the n parameter. The n parameter must be an unsigned decimal integer with range 0-255. If you omit the n parameter, the exit status is that of the last command executed. An end-of-file character also exits the shell, unless the ignoreeof option of the set special command is turned on. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
export -p [Name[= Value]] ... | Marks the specified names for automatic export to the environment of subsequently executed commands.
-p writes to standard output the names and values of all exported variables, in the following format: "export %s= %s\n", <name> <value> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
newgrp [Group] | Equivalent to the exec/usr/bin/newgrp [Group] command.
Note: This command does not return. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
readonly -p [Name[= Value]] ... | Marks the names specified by the Name parameter as read-only. These names cannot be changed by subsequent assignment.
-p writes to standard output the names and values of all exported variables, in the following format: "export %s= %s\n", <name> <value> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return [n] | Causes a shell function to return to the invoking script. The return status is specified by the n variable. If you omit the n variable, the return status is that of the last command executed. If you invoke the return command outside of a function or a script, then it is the same as an exit command. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
set [+ |-abCefhkmnostuvx ] [+ |-o Option]... [+ |-A Name] [Argument ...] | If no options or arguments are specified, the set command writes the names and values of all shell variables in the collation sequence of the current locale. When options are specified, they will set or unset attributes of the shell, as described below. When arguments are specified, they will cause positional parameters to be set or unset, as described below. The flags for this command are interpreted as follows:
Preceding any of the set command flags with a + (plus sign) rather than a - (minus sign) turns off the flag. You can use these flags when you invoke the shell. The current set of flags is found in the $- parameter. Unless you specify the -A flag, the remaining arguments are positional parameters and are assigned, in order, to $1, $2, ..., and so forth. If no arguments are given, the names and values of all named parameters are printed to standard output. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
shiftn [] | Renames the positional parameters, beginning with $n+1 ... through $1 .... The default value of the n parameter is 1. The n parameter is any arithmetic expression that evaluates to a nonnegative number less than or equal to the $# parameter. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
times | Prints the accumulated user and system times for the shell and for processes run from the shell. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
trapCommandSignal [] [] ... | Runs the specified command when the shell receives the specified signal or signals. The Command parameter is read once when the trap is set and once when the trap is taken. The Signal parameter 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 the command is a - (minus sign), all traps are reset to their original values. If you omit the command and the first signal is a numeric signal number, then the ksh command resets the value of the Signal parameter or parameters to the original values. Note: If you omit the command and the first signal is a symbolic name, the signal is interpreted as a command. If the value of the Signal parameter is the ERR signal, the specified command is carried out whenever a command has a nonzero exit status. If the signal is DEBUG, then the specified command is carried out after each command. If the value of the Signal parameter is the 0 or EXIT signal and the trap command is executed inside the body of a function, the specified command is carried out after the function completes. If the Signal parameter is 0 or EXIT for a trap command set outside any function, the specified command is carried out on exit from the shell. The trap command with no arguments prints a list of commands associated with each signal number. For a complete list of Signal parameter values, used in the trap command without the SIG prefix, refer to the sigaction, sigvec, or signal subroutine in the AIX Version 4.3 Technical Reference: Base Operating System and Extensions Volume 2. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
typeset [+HLRZfilrtux [n]] [Name[= Value]] ... | Sets attributes and values for shell parameters. When invoked inside a function, a new instance of the Name parameter is created. The parameter value and type are restored when the function completes. You can specify the following flags with the typeset command:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
unset [-fv ] Name ... | Unsets the values and attributes of the parameters given by the list of names. If -v is specified, Name refers to a variable name, and the shell will unset it and remove it from the environment. Read-only variables cannot be unset. Unsetting the ERRNO, LINENO, MAILCHECK, OPTARG, OPTIND, RANDOM, SECONDS, TMOUT, and _ (underscore) variables removes their special meanings even if they are subsequently assigned.
If the -f flag is set, then Name refers to a function name, and the shell will unset the function definition. |
The Korn Shell provides the following regular built-in commands:
alias fg print ulimit bg getopts pwd umask cd jobs read unalias command kill setgroups wait echo let test whence fc
alias [-t ] [-x ] [AliasName[= String]] ... | Creates or redefines alias definitions or writes existing alias definitions to standard output.
For more information, refer to the alias command in the AIX Version 4.3 Commands Reference. | ||||||||||||||||||||
bg [JobID...] | Puts each specified job into the background. The current job is put in the background if a JobID parameter is not specified. Refer to "Job Control in the Korn Shell or POSIX Shell"
for more information about job control.
For more information about running jobs in the background, refer to the bg command in the AIX Version 4.3 Commands Reference. | ||||||||||||||||||||
cd [Argument] | |||||||||||||||||||||
cd Old New | This command can be in either of two forms. In the first form, it changes the current directory to the one specified by the Argument parameter. If the value of the Argument parameter is - (minus sign), the directory is changed to the previous directory. The HOME shell variable is the default value of the Argument parameter. The PWD variable is set to the current directory.
The CDPATH shell variable defines the search path for the directory containing the value of the Argument parameter. Alternative directory names are separated by a : (colon). The default path is null, specifying the current directory. The current directory is specified by a null path name, which appears immediately after the equal sign or between the colon delimiters anywhere in the path list. If the specified argument begins with a / (slash), the search path is not used. Otherwise, each directory in the path is searched for the argument. The second form of the cd command substitutes the string specified by the New variable for the string specified by the Old variable in the current directory name, PWD, and tries to change to this new directory. | ||||||||||||||||||||
command [-p ] CommandName [Argument ...] | |||||||||||||||||||||
command [-v | -V ] CommandName | Command causes the shell to treat the specified command and arguments as a simple command, suppressing shell function lookup.
For more information, refer to the command command in the AIX Version 4.3 Commands Reference. | ||||||||||||||||||||
echo [String ...] | Writes character strings to standard output. Refer to the echo command for usage and description. The -n flag is not supported. | ||||||||||||||||||||
fc [-r ] [-e Editor] [First [Last]] | |||||||||||||||||||||
fc -l [-n ] [-r ] [First [Last]] | |||||||||||||||||||||
fc -s [Old= New] [First] | Displays the contents of your command history file or invokes an editor to modify and re-executes commands previously entered in the shell.
For more information, refer to the fc command in the AIX Version 4.3 Commands Reference. | ||||||||||||||||||||
fg [JobID] | Brings each job specified into the foreground. If you do not specify any jobs, the command brings the current job into the foreground.
For more information about running jobs in the foreground, refer to the fg command in the AIX Version 4.3 Commands Reference. | ||||||||||||||||||||
getopts OptionString Name [Argument ...] | Checks the Argument parameter for legal options.
For more information, refer to the getopts command in the AIX Version 4.3 Commands Reference. | ||||||||||||||||||||
jobs [-l | -n | -p ] [JobID ...] | Displays the status of jobs started in the current shell environment. If no specific job is specified with the JobID parameter, status information for all active jobs is displayed. If a job termination is reported, the shell removes that job's process ID from the list of those known by the current shell environment.
For more information, refer to the jobs command in the AIX Version 4.3 Commands Reference. | ||||||||||||||||||||
To Send Signal to Processes: | |||||||||||||||||||||
kill [ -s { SignalName | SignalNumber } ] ProcessID... | |||||||||||||||||||||
kill [ -SignalName | -SignalNumber ] ProcessID... | |||||||||||||||||||||
To List Signal Names: | |||||||||||||||||||||
kill -l [ ExitStatus ] | Sends a signal (by default, the SIGTERM signal) to a running process. This default action normally stops processes. If you want to stop a process, specify the process ID (PID) in the ProcessID variable. The shell reports the PID of each process that is running in the background (unless you start more than one process in a pipeline, in which case the shell reports the number of the last process). You can also use the ps command to find the process ID number of commands.
For more information, refer to the kill command in the AIX Version 4.3 Commands Reference. | ||||||||||||||||||||
let Expression ... | Evaluates specified arithmetic expressions. The exit status is 0 if the value of the last expression is nonzero, and 1 otherwise. Refer to "Arithmetic Evaluation in the Korn Shell or POSIX Shell" for more information. | ||||||||||||||||||||
print [-Rnprsu [n]] [Argument ...] | Prints shell output. If you do not specify any flags, or if the - (minus sign) or -- (dash) flags are specified, the arguments are printed to standard output as described by the echo command. The flags do the following:
| ||||||||||||||||||||
pwd Equivalent to print -r - $PWD. | Note: The internal Korn shell pwd command does not support symbolic links. | ||||||||||||||||||||
read [-prsu [n ]] [Name?Prompt] [Name...] | Takes shell input. One line is read and broken up into fields, using the characters in the IFS variable as separators.
For more information, refer to the read command in the AIX Version 4.3 Commands Reference. | ||||||||||||||||||||
setgroups | Executes the /usr/bin/setgroups command, which runs as a separate shell. See the setgroups command for information on how this command works. There is one difference, however. The setgroups built-in command invokes a subshell, but the setgroups command replaces the currently executing shell. Since the built-in command is supported only for compatibility, it is recommended that scripts use the absolute path name /usr/bin/setgroups rather than the shell built-in command. | ||||||||||||||||||||
test | Same as [expression]. See "Conditional Expressions" for usage and description. | ||||||||||||||||||||
ulimit [-HSacdfmst ] [Limit] | Sets or displays user-process resource limits as defined in the /etc/security/limits file. This file contains six default limits:
fsize = 2097151 core = 2048 cpu = 3600 data = 131072 rss = 65536 stack = 8192 These values are used as default settings when a new user is added to the system. The values are set with the mkuser command when the user is added to the system, or changed with the chuser command. Limits are categorized as either soft or hard. Users may change their soft limits, up to the maximum set by the hard limits, with the ulimit command. You must have root user authority to change resource hard limits. Many systems do not contain one or more of these limits. The limit for a specified resource is set when the Limit parameter is specified. The value of the Limit parameter can be a number in the unit specified with each resource, or the value unlimited. You can specify the following ulimit command flags:
The current resource limit is printed when you omit the Limit variable. The soft limit is printed unless you specify the -H flag. When you specify more than one resource, the limit name and unit is printed before the value. If no option is given, the -f flag is assumed. When you change the value, set both hard and soft limits to Limit unless you specify -H or -S. For more information about user and system resource limits, refer to the getrlimit, setrlimit, or vlimit subroutine in the AIX Version 4.3 Technical Reference: Base Operating System and Extensions Volume 1. | ||||||||||||||||||||
umask [-S ] [Mask] | Determines file permissions. This value, along with the permissions of the creating process, determines a file's permissions when the file is created. The default is 022. If the Mask parameter is not specified, the umask command displays to standard output the file mode creation mask of the current shell environment.
For more information about file permissions, refer to the umask command in the AIX Version 4.3 Commands Reference. | ||||||||||||||||||||
unalias -a | |||||||||||||||||||||
unalias AliasName... | Removes the definition for each alias name specified, or removes all alias definitions if the -a flag is used. Alias definitions are removed from the current shell environment.
For more information, refer to the unalias command in the AIX Version 4.3 Commands Reference. | ||||||||||||||||||||
wait [ProcessID...] | Waits for the specified job and terminates. If you do not specify a job, the command waits for all currently active child processes. The exit status from this command is that of the process for which it waits.
For more information, refer to the wait command in the AIX Version 4.3 Commands Reference. | ||||||||||||||||||||
whence [-pv ] Name ... | Indicates, for each name specified, how it would be interpreted if used as a command name. When used without either flag, whence will display the absolute pathname, if any, that corresponds to each name.
|