A. Shell Built-in Command Reference


The following text is taken directly from the Bourne shell manual page (sh(1)). It originated from a Sun SPARCstation running the Solaris 2.4 operating system, an SVR4 compliant UNIX. According to the man page, the information presented was last modified on October 11, 1993. Regardless of this fact, these commands should be consistent with any SVR4 or POSIX compliant system. Note that some descriptions will point to a man page by listing the command name followed by a number enclosed in parentheses. The reader is urged to refer to the declared man page for further reference.


. filename
Read and execute commands from filename and return. The search path specified by PATH is used to find the directory containing filename.

:
No effect; the command does nothing. A zero exit code is returned.

break [ n ]
Exit from the enclosing for or while loop, if any. If n is specified, break n levels.

continue [ n ]
Resume the next iteration of the enclosing for or while loop. If n is specified, resume at the n-th enclosing loop.

cd [ argument ]
Change the current directory to argument. The shell parameter HOME is the default argument. The shell parameter CDPATH defines the search path for the directory containing argument. Alternative directory names are separated by a colon (:). The default path is null (specifying the current directory). Note: The current directory is specified by a null path name, which can appear immediately after the equal sign or between the colon delimiters anywhere else in the path list. If argument begins with a / the search path is not used. Otherwise, each directory in the path is searched for argument.

echo [ argument ... ]
Echo arguments. See echo(1) for usage and description.

eval [ argument ... ]
The arguments are read as input to the shell and the resulting command(s) executed.

exec [ argument ... ]
The command specified by the arguments is executed in place of this shell without creating a new process. Input/output arguments may appear and, if no other arguments are given, cause the shell input/output to be modified.

exit [ n ]
Causes a 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 EOF will also cause the shell to exit.)

export [ name ... ]
The given names are marked for automatic export to the environment of subsequently executed commands. If no arguments are given, variable names that have been marked for export during the current shell's execution are listed. (Variable names exported from a parent shell are listed only if they have been exported again during the current shell's execution.) Function names are not exported.

getopts
Use in shell scripts to support command syntax stan- dards (see intro(1)); it parses positional parameters and checks for legal options. See getoptcvt(1) for usage and description.

hash [ -r ] [ name ... ]
For each name, the location in the search path of the command specified by name is determined and remembered by the shell. The -r option causes the shell to forget all remembered locations. If no arguments are given, information about remembered commands is presented. Hits is the number of times a command has been invoked by the shell process. Cost is a measure of the work required to locate a command in the search path. If a command is found in a "relative" directory in the search path, after changing to that directory, the stored location of that command is recalculated. Com- mands for which this will be done are indicated by an asterisk (*) adjacent to the hits information. Cost will be incremented when the recalculation is done.

newgrp [ argument ]
Equivalent to exec newgrp argument. See newgrp(1M) for usage and description.

pwd
Print the current working directory. See pwd(1) for usage and description.

read name ...
One line is read from the standard input and, using the internal field separator, IFS (normally space or tab), to delimit word boundaries, the first word is assigned to the first name, the second word to the second name, etc., with leftover words assigned to the last name. Lines can be continued using \newline. Characters other than newline can be quoted by preceding them with a backslash. These backslashes are removed before words are assigned to names, and no interpretation is done on the character that follows the backslash. The return code is 0, unless an EOF is encountered.

readonly [ name ... ]
The given names are marked readonly and the values of the these names may not be changed by subsequent assignment. If no arguments are given, a list of all readonly names is printed.

return [ n ]
Causes a function to exit with the return value specified by n. If n is omitted, the return status is that of the last command executed.

set [ --aefhkntuvx [ argument ... ] ]
-a Mark variables which are modified or created for export. -e Exit immediately if a command exits with a nonzero exit status. -f Disable file name generation. -h Locate and remember function commands as functions are defined (function commands are normally located when the function is executed). -k All keyword arguments are placed in the environment for a command, not just those that precede the command name. -n Read commands but do not execute them. -t Exit after reading and executing one command. -u Treat unset variables as an error when substituting. -v Print shell input lines as they are read. -x Print commands and their arguments as they are executed. -- Do not change any of the flags; useful in setting $1 to -. Using + rather than - causes these flags to be turned off. These flags can also be used upon invocation of the shell. The current set of flags may be found in $- . The remaining arguments are positional parameters and are assigned, in order, to $1, $2, .... If no arguments are given the values of all names are printed.

shift [ n ]
The positional parameters from $n+1 ... are renamed $1 ... . If n is not given, it is assumed to be 1.

stop pid ...
Halt execution of the process number pid. (see ps(1)).

test
Evaluate conditional expressions. See test(1) for usage and description.

times
Print the accumulated user and system times for processes run from the shell.

trap [ argument ] [ n ] ...
The command argument is to be read and executed when the shell receives numeric or symbolic signal(s) (n). (Note: argument is scanned once when the trap is set and once when the trap is taken.) Trap commands are executed in order of signal number or corresponding symbolic names. Any attempt to set a trap on a signal that was ignored on entry to the current shell is ineffective. An attempt to trap on signal 11 (memory fault) produces an error. If argument is absent all trap(s) n 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 n is 0 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.

type [ name ... ]
For each name, indicate how it would be interpreted if used as a command name.

ulimit [ -[HS][a | cdfnstv] ] OR ulimit [ -[HS][c | d | f | n | s | t | v] ] limit
ulimit prints or sets hard or soft resource limits. These limits are described in getrlimit(2). If limit is not present, ulimit prints the specified limits. Any number of limits may be printed at one time. The -a option prints all limits. If limit is present, ulimit sets the specified limit to limit. The string unlimited requests the largest valid limit. Limits may be set for only one resource at a time. Any user may set a soft limit to any value below the hard limit. Any user may lower a hard limit. Only a super-user may raise a hard limit; see su(1M). The -H option specifies a hard limit. The - S option specifies a soft limit. If neither option is speci- fied, ulimit will set both limits and print the soft limit. The following options specify the resource whose limits are to be printed or set. If no option is specified, the file size limit is printed or set. -c maximum core file size (in 512-byte blocks) -d maximum size of data segment or heap (in kbytes) -f maximum file size (in 512-byte blocks) -n maximum file descriptor plus 1 -s maximum size of stack segment (in kbytes) -t maximum CPU time (in seconds) -v maximum size of virtual memory (in kbytes).

umask [ nnn ]
The user file-creation mask is set to nnn (see umask(1)). If nnn is omitted, the current value of the mask is printed.

unset [ name ... ]
For each name, remove the corresponding variable or function value. The variables PATH, PS1, PS2, MAILCHECK, and IFS cannot be unset.

wait [ n ]
Wait for your background process whose process id is n and report its termination status. If n is omitted, all your shell's currently active background processes are waited for and the return code will be zero.