old-sh.html revision 3f54fd611f536639ec30dd53c48e5ec1897cc7d9
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<META NAME="generator" CONTENT="troff2html (AT&T Labs Research) 04/01/97 -man">
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<H3><TABLE WIDTH=100%><TR><TH ALIGN=LEFT> SH ( 1 ) <TH ALIGN=CENTER>USER COMMANDS<TH ALIGN=RIGHT>SH ( 1 )</TABLE>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<H3><A NAME="NAME">NAME </A></H3>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<DD></STRONG></FONT>sh, rsh - shell, the standard/restricted command and programming language
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<H3><A NAME="SYNOPSIS">SYNOPSIS </A></H3>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<DD></STRONG></FONT><STRONG>sh </STRONG>[ <STRONG>±abcefhikmnoprstuvxCD </STRONG>] [ <STRONG>-R </STRONG>file ] [ <STRONG>±o </STRONG>option ] . . .
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortersh </STRONG>[ <STRONG>±abcefhikmnoprstuvxCD </STRONG>] [ <STRONG>-R </STRONG>file ] [ <STRONG>±o </STRONG>option ] . . .
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<H3><A NAME="DESCRIPTION">DESCRIPTION </A></H3>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<DD></STRONG></FONT><EM>Sh </EM>is a command and programming language that executes commands read from
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortea terminal or a file.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<EM>Rsh </EM>is a restricted version of the standard command interpreter <EM>sh</EM>; it
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteis used to set up login names and execution environments whose capabilities
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteare more controlled than those of the standard shell.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteSee <EM>Invocation </EM>below for the meaning of arguments to the shell.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<DD></STRONG></FONT>A <EM>metacharacter </EM>is one of the following characters: <DL COMPACT><STRONG><P>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte; & ( ) | < > new-line space tab</STRONG> </DL>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteA <EM>blank </EM>is a <STRONG>tab </STRONG>or a <STRONG>space</STRONG>.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteAn <EM>identifier </EM>is a sequence of letters, digits, or underscores starting
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortewith a letter or underscore.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteIdentifiers are used as components of <EM>variable </EM>names.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteA <EM>vname </EM>is a sequence of one or more identifiers separated by a <STRONG><FONT SIZE=+1>.</FONT></STRONG> and optionally
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortepreceded by a <STRONG><FONT SIZE=+1>.</FONT></STRONG>.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteVnames are used as function and variable names.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteA <EM>word </EM>is a sequence of <EM>characters </EM>from the character set defined by the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecurrent locale, excluding non-quoted <EM>metacharacters</EM>.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteA <EM>command </EM>is a sequence of characters in the syntax of the shell language.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThe shell reads each command and carries out the desired action either
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedirectly or by invoking separate utilities.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteA built-in command is a command that is carried out by the shell itself
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortewithout creating a separate process.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteSome commands are built-in purely for convenience and are not documented
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteBuilt-ins that cause side effects in the shell environment and built-ins
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortethat are found before performing a path search (see <A HREF="#Execution"><EM>Execution </EM></A>below) are
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedocumented here.
0c034175550709323575bc82b80a835256239e86Jiri SvobodaFor historical reasons, some of these built-ins behave differently than
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteother built-ins and are called <EM>special built-ins</EM>.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<DD></STRONG></FONT>A <EM>simple-command </EM>is a list of variable assignments (see <A HREF="#Variable Assignments"><EM>Variable Assignments
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte</EM></A>below) or a sequence of <EM>blank </EM>separated words which may be preceded by
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortea list of variable assignments (see <A HREF="#Environment"><EM>Environment </EM></A>below).
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThe first word specifies the name of the command to be executed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteExcept as specified below, the remaining words are passed as arguments
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteto the invoked command.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThe command name is passed as argument 0 (see <A HREF="exec(2)"><EM>exec</EM>(2)</A>).
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThe <EM>value </EM>of a simple-command is its exit status; 0-255 if it terminates
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortenormally; 256+<EM>signum </EM> if it terminates abnormally (the name of the signal
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecorresponding to the exit status can be obtained via the <STRONG>-l </STRONG>option of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteA <EM>pipeline </EM>is a sequence of one or more <EM>commands </EM>separated by <STRONG>|</STRONG>.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThe standard output of each command but the last is connected by a <EM>pipe</EM>(2)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteto the standard input of the next command.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteEach command, except possibly the last, is run as a separate process; the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteshell waits for the last command to terminate.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThe exit status of a pipeline is the exit status of the last command.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteEach pipeline can be preceded by the <EM>reserved word </EM><STRONG>! </STRONG>which causes the exit
0c034175550709323575bc82b80a835256239e86Jiri Svobodastatus of the pipeline to become 0 if the exit status of the last command
0c034175550709323575bc82b80a835256239e86Jiri Svobodais non-zero, and 1 if the exit status of the last command is 0.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteA <EM>list </EM>is a sequence of one or more pipelines separated by <STRONG>;</STRONG>, <STRONG>&</STRONG>, <STRONG>|&</STRONG>, <STRONG>&&</STRONG>,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteor <STRONG>| |</STRONG>, and optionally terminated by <STRONG>;</STRONG>, <STRONG>&</STRONG>, or <STRONG>|&</STRONG>.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteOf these five symbols, <STRONG>;</STRONG>, <STRONG>&</STRONG>, and <STRONG>|& </STRONG>have equal precedence, which is lower
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortethan that of <STRONG>&& </STRONG>and <STRONG>| |</STRONG>.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThe symbols <STRONG>&& </STRONG>and <STRONG>| | </STRONG>also have equal precedence.
0c034175550709323575bc82b80a835256239e86Jiri SvobodaA semicolon (<STRONG>;</STRONG>) causes sequential execution of the preceding pipeline;
0c034175550709323575bc82b80a835256239e86Jiri Svobodaan ampersand (<STRONG>&</STRONG>) causes asynchronous execution of the preceding pipeline
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte(i.e., the shell does <EM>not </EM>wait for that pipeline to finish).
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThe symbol <STRONG>|& </STRONG>causes asynchronous execution of the preceding pipeline with
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortea two-way pipe established to the parent shell; the standard input and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteoutput of the spawned pipeline can be written to and read from by the parent
0c034175550709323575bc82b80a835256239e86Jiri Svobodashell by applying the redirection operators <STRONG><& </STRONG>and <STRONG>>& </STRONG>with arg <STRONG>p </STRONG>to commands
0c034175550709323575bc82b80a835256239e86Jiri Svobodaand by using <STRONG>-p </STRONG>option of the built-in commands <STRONG>read </STRONG>and <STRONG>print </STRONG>described
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThe symbol <STRONG>&& </STRONG>( <STRONG>| |</STRONG> ) causes the <EM>list </EM>following it to be executed only
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteif the preceding pipeline returns a zero (non-zero) value.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteOne or more new-lines may appear in a <EM>list </EM>instead of a semicolon, to delimit
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteA <EM>command </EM>is either a simple-command or one of the following.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteUnless otherwise stated, the value returned by a command is that of the
0c034175550709323575bc82b80a835256239e86Jiri Svobodalast simple-command executed in the command.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefor</STRONG> <EM>vname </EM> [ <STRONG>in</STRONG> <EM>word </EM> . . .
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ] <STRONG>;do</STRONG><EM>list </EM><STRONG>;done</STRONG>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<DD>Each time a <STRONG>for </STRONG>command is executed, <EM>vname </EM>is set to the next <EM>word </EM>taken
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteIf <STRONG>in</STRONG><EM> word </EM>. . .
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteis omitted, then the <STRONG>for </STRONG>command executes the <STRONG>do</STRONG> <EM>list </EM> once for each positional
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteparameter that is set starting from <STRONG>1 </STRONG>(see <A HREF="#Parameter Expansion"><EM>Parameter Expansion </EM></A>below).
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteExecution ends when there are no more words in the list.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefor ((</STRONG> [ <EM>expr1 </EM> ] <STRONG>;</STRONG> [ <EM>expr2 </EM> ] <STRONG>;</STRONG> [ <EM>expr3 </EM> ] <STRONG>))</STRONG><STRONG>;do</STRONG><EM>list </EM><STRONG>;done</STRONG>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<DD>The arithmetic expression <EM>expr1 </EM>is evaluated first (see <A HREF="#Arithmetic Evaluation"><EM>Arithmetic Evaluation
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThe arithmetic expression <EM>expr2 </EM>is repeatedly evaluated until it evaluates
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteto zero and when non-zero, <EM>list </EM>is executed and the arithmetic expression
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteIf any expression is omitted, then it behaves as if it evaluated to 1.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteselect</STRONG> <EM>vname </EM> [ <STRONG>in</STRONG> <EM>word </EM> . . .
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ] <STRONG>;do</STRONG><EM>list </EM><STRONG>;done</STRONG>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<DD>A <STRONG>select </STRONG>command prints on standard error (file descriptor 2) the set of
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteIf <STRONG>in</STRONG><EM> word </EM>. . .
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteis omitted, then the positional parameters starting from <STRONG>1 </STRONG>are used instead
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte(see <A HREF="#Parameter Expansion"><EM>Parameter Expansion </EM></A>below).
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThe <FONT SIZE=-1><STRONG>PS3 </STRONG></FONT>prompt is printed and a line is read from the standard input.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteIf this line consists of the number of one of the listed <EM>word</EM>s, then the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevalue of the variable <EM>vname </EM>is set to the <EM>word </EM>corresponding to this number.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteIf this line is empty, the selection list is printed again.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteOtherwise the value of the variable <EM>vname </EM>is set to <EM>null</EM>.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThe contents of the line read from standard input is saved in the variable
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte</FONT>The <EM>list </EM>is executed for each selection until a <STRONG>break </STRONG>or <EM>end-of-file </EM>is
0c034175550709323575bc82b80a835256239e86Jiri SvobodaIf the <FONT SIZE=-1><STRONG>REPLY </STRONG></FONT>variable is set to <EM>null </EM>by the execution of <EM>list</EM>, then the
0c034175550709323575bc82b80a835256239e86Jiri Svobodaselection list is printed before displaying the <FONT SIZE=-1><STRONG>PS3 </STRONG></FONT>prompt for the next
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecase</STRONG> <EM>word </EM> <STRONG>in</STRONG> [ [ <STRONG>(</STRONG> ]<EM>pattern </EM> [ | <EM>pattern </EM> ]. . .<STRONG>)</STRONG><EM>list </EM><STRONG>;;</STRONG> ]. . .<STRONG>esac</STRONG>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<DD>A <STRONG>case </STRONG>command executes the <EM>list </EM>associated with the first <EM>pattern </EM>that
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThe form of the patterns is the same as that used for file-name generation
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte(see <A HREF="#File Name Generation"><EM>File Name Generation </EM></A>below).
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThe <STRONG>;; </STRONG>operator causes execution of <STRONG>case </STRONG>to terminate.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteIf <STRONG>;& </STRONG>is used in place of <STRONG>;; </STRONG>the next subsequent list, if any, is executed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteif</STRONG> <EM>list </EM> <STRONG>;then</STRONG> <EM>list </EM> [ <STRONG>elif</STRONG> <EM>list </EM> <STRONG>;then</STRONG><EM>list </EM> ]. . .[ <STRONG>;else</STRONG><EM>list </EM> ]<STRONG>;fi</STRONG>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<DD>The <EM>list </EM>following <STRONG>if</STRONG> is executed and, if it returns a zero exit status,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortethe <EM>list </EM>following the first <STRONG>then </STRONG>is executed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteOtherwise, the <EM>list </EM>following <STRONG>elif</STRONG> is executed and, if its value is zero,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortethe <EM>list </EM>following the next <STRONG>then </STRONG>is executed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteFailing each successive <STRONG>elif </STRONG><EM>list </EM>, the <STRONG>else </STRONG><EM>list </EM>is executed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteIf the <STRONG>if </STRONG><EM>list </EM>has non-zero exit status and there is no <STRONG>else </STRONG><EM>list</EM>, then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortethe <STRONG>if </STRONG>command returns a zero exit status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortewhile</STRONG> <EM>list </EM> <STRONG>;do</STRONG> <EM>list </EM> <STRONG>;done</STRONG>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuntil</STRONG> <EM>list </EM> <STRONG>;do</STRONG> <EM>list </EM> <STRONG>;done</STRONG>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<DD>A <STRONG>while </STRONG>command repeatedly executes the <STRONG>while </STRONG><EM>list </EM>and, if the exit status
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteof the last command in the list is zero, executes the <STRONG>do </STRONG><EM>list</EM>; otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortethe loop terminates.
0c034175550709323575bc82b80a835256239e86Jiri SvobodaIf no commands in the <STRONG>do </STRONG><EM>list </EM>are executed, then the <STRONG>while </STRONG>command returns
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortea zero exit status; <STRONG>until </STRONG>may be used in place of <STRONG>while </STRONG>to negate the loop
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetermination test.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte((</STRONG><EM>expression </EM><STRONG>))</STRONG>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<DD>The <EM>expression </EM>is evaluated using the rules for arithmetic evaluation described
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteIf the value of the arithmetic expression is non-zero, the exit status
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteis 0, otherwise the exit status is 1.
0c034175550709323575bc82b80a835256239e86Jiri Svoboda<DD>Execute <EM>list </EM>in a separate environment.
0c034175550709323575bc82b80a835256239e86Jiri SvobodaNote, that if two adjacent open parentheses are needed for nesting, a space
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortemust be inserted to avoid evaluation as an arithmetic command as described
0c034175550709323575bc82b80a835256239e86Jiri Svoboda{ </STRONG><EM>list </EM><STRONG>;}</STRONG>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteNote that unlike the metacharacters <STRONG>( </STRONG>and <STRONG>)</STRONG>, <STRONG>{ </STRONG>and <STRONG>} </STRONG>are <EM>reserved word</EM>s
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteand must occur at the beginning of a line or after a <STRONG>; </STRONG>in order to be recognized.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte[[</STRONG><EM> expression </EM><STRONG>]]</STRONG>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<DD>Evaluates <EM>expression </EM>and returns a zero exit status when <EM>expression </EM>is
0c034175550709323575bc82b80a835256239e86Jiri SvobodaSee <EM>Conditional Expressions </EM>below, for a description of <EM>expression</EM>.
0c034175550709323575bc82b80a835256239e86Jiri Svobodafunction</STRONG> <EM>varname </EM> <STRONG>{</STRONG> <EM>list </EM> <STRONG>;}</STRONG>
0c034175550709323575bc82b80a835256239e86Jiri Svobodavarname </EM> <STRONG>() {</STRONG> <EM>list </EM> <STRONG>;}</STRONG>
0c034175550709323575bc82b80a835256239e86Jiri Svoboda<DD>Define a function which is referenced by <EM>varname</EM>.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteA function whose <EM>varname </EM>contains a <STRONG><FONT SIZE=+1>.</FONT> </STRONG>is called a discipline function and
0c034175550709323575bc82b80a835256239e86Jiri Svobodathe portion of the <EM>varname </EM>preceding the last <STRONG><FONT SIZE=+1>.</FONT> </STRONG>must refer to an existing
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThe body of the function is the <EM>list </EM>of commands between <STRONG>{ </STRONG>and <STRONG>}</STRONG>.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteA function defined with the <STRONG>function</STRONG> <EM>varname </EM> syntax can also be used as
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortean argument to the <STRONG>.</STRONG> special built-in command to get the equivalent behavior
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteas if the <EM>varname </EM><STRONG>()</STRONG> syntax were used to define it.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetime</STRONG> [ <EM>pipeline </EM> ]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<DD>If <EM>pipeline </EM> is omitted the user and system time for the current shell
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteand completed child processes is printed on standard error.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteOtherwise, <EM>pipeline </EM>is executed and the elapsed time as well as the user
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteand system time are printed on standard error.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThe following reserved words are recognized as reserved only when they
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteare the first word of a command and are not quoted: <DL COMPACT><STRONG><P>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteif then else elif fi case esac for while until do done { } function select
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<H3><A NAME="Variable Assignments">Variable Assignments.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<DD></STRONG></FONT>One or more variable assignments can start a simple command or can be arguments
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteto the <STRONG>typeset</STRONG>, <STRONG>export</STRONG>, or <STRONG>readonly </STRONG>special built-in commands.
0c034175550709323575bc82b80a835256239e86Jiri SvobodaThe syntax for an <EM>assignment </EM> is of the form: <DL COMPACT><EM>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevarname </EM><STRONG>=</STRONG><EM>word </EM>
0c034175550709323575bc82b80a835256239e86Jiri Svobodavarname </EM><STRONG>[</STRONG><EM>word </EM><STRONG>]</STRONG>=<STRONG></STRONG><EM>word </EM><STRONG>
0c034175550709323575bc82b80a835256239e86Jiri Svoboda<DD></STRONG>No space is permitted between <EM>varname </EM> and the <STRONG>=</STRONG> or between <STRONG>=</STRONG> and <EM>word </EM>.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevarname </EM><STRONG>=(</STRONG><EM>assign_list </EM><STRONG>)</STRONG>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<DD>No space is permitted between <EM>varname </EM> and the <STRONG>=</STRONG>.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteAn <EM>assign_list </EM> can be one of the following: <DL COMPACT><DL COMPACT><EM>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteword </EM> ...
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<DD>Indexed array assignment.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte[</STRONG><EM>word </EM><STRONG>]=</STRONG><EM>word </EM> . . .
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<DD>Associative array assignment.
0c034175550709323575bc82b80a835256239e86Jiri Svobodaassignment </EM> . . .
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<DD>Nested variable assignment.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypeset</STRONG> [ <EM>options</EM> ] <EM>assignment </EM> . . .
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<DD>Nested variable assignment.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMultiple assignments can be specified by separating each of them with a
0c034175550709323575bc82b80a835256239e86Jiri Svoboda<DD></STRONG></FONT>A word beginning with <STRONG># </STRONG>causes that word and all the following characters
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteup to a new-line to be ignored.
0c034175550709323575bc82b80a835256239e86Jiri Svoboda<DD></STRONG></FONT>The first word of each command is replaced by the text of an <STRONG>alias </STRONG>if an
0c034175550709323575bc82b80a835256239e86Jiri Svoboda<STRONG>alias </STRONG>for this word has been defined.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteAn <STRONG>alias </STRONG>name consists of any number of characters excluding metacharacters,
0c034175550709323575bc82b80a835256239e86Jiri Svobodaquoting characters, file expansion characters, parameter expansion and
0c034175550709323575bc82b80a835256239e86Jiri Svobodacommand substitution characters, and <STRONG>=</STRONG>.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThe replacement string can contain any valid shell script including the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortemetacharacters listed above.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThe first word of each command in the replaced text, other than any that
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteare in the process of being replaced, will be tested for aliases.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteIf the last character of the alias value is a <EM>blank </EM>then the word following
0c034175550709323575bc82b80a835256239e86Jiri Svobodathe alias will also be checked for alias substitution.
0c034175550709323575bc82b80a835256239e86Jiri SvobodaAliases can be used to redefine built-in commands but cannot be used to
0c034175550709323575bc82b80a835256239e86Jiri Svobodaredefine the reserved words listed above.
0c034175550709323575bc82b80a835256239e86Jiri SvobodaAliases can be created and listed with the <STRONG>alias </STRONG>command and can be removed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteAliasing </EM>is performed when scripts are read, not while they are executed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteTherefore, for an alias to take effect, the <STRONG>alias </STRONG>definition command has
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteto be executed before the command which references the alias is read.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThe following aliases are compiled into the shell but can be unset or redefined:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteautoload='typeset -fu' </STRONG>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecommand='command ' </STRONG>
0c034175550709323575bc82b80a835256239e86Jiri Svobodafc=hist </STRONG>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefloat='typeset -E' </STRONG>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefunctions='typeset -f' </STRONG>
0c034175550709323575bc82b80a835256239e86Jiri Svobodahash='alias -t - -' </STRONG>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortehistory='hist -l' </STRONG>
af9f043dfadcd803f0bc2000663d0c68ff6a22d8Jiri Svobodainteger='typeset -i' </STRONG>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortenameref='typeset -n' </STRONG>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortenohup='nohup ' </STRONG>
0c034175550709323575bc82b80a835256239e86Jiri Svobodar='hist -s' </STRONG>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteredirect='command exec' </STRONG>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestop='kill -s <FONT SIZE=-1>STOP</FONT>' </STRONG>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesuspend='kill -s <FONT SIZE=-1>STOP</FONT> $$' </STRONG>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetimes='{ { time;} 2>&1;}' </STRONG>
0c034175550709323575bc82b80a835256239e86Jiri Svobodatype='whence -v' </STRONG>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<H3><A NAME="Tilde Substitution">Tilde Substitution.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<DD></STRONG></FONT>After alias substitution is performed, each word is checked to see if it
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteFor tilde substitution, <EM>word </EM>also refers to the <EM>word </EM>portion of parameter
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteexpansion (see <A HREF="#Parameter Expansion"><EM>Parameter Expansion </EM></A>below).
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteIf it does, then the word up to a <STRONG>/ </STRONG>is checked to see if it matches a user
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortename in the password database (often the <STRONG>/etc/passwd </STRONG>file).
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteIf a match is found, the <STRONG>~ </STRONG>and the matched login name are replaced by the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortelogin directory of the matched user.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteIf no match is found, the original text is left unchanged.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteA <STRONG>~ </STRONG>by itself, or in front of a <STRONG>/</STRONG>, is replaced by <FONT SIZE=-1><STRONG>$HOME</STRONG>.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte</FONT>A <STRONG>~ </STRONG>followed by a <STRONG>+ </STRONG>or <STRONG>- </STRONG>is replaced by the value of <STRONG><FONT SIZE=-1>$PWD </FONT></STRONG>and <STRONG><FONT SIZE=-1>$OLDPWD </FONT></STRONG>respectively.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteIn addition, when expanding a <EM>variable assignment</EM>, <EM>tilde </EM>substitution is
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteattempted when the value of the assignment begins with a <STRONG>~</STRONG>, and when a
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<STRONG>~ </STRONG>appears after a <STRONG>:</STRONG>.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThe <STRONG>: </STRONG>also terminates a <STRONG>~ </STRONG>login name.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<H3><A NAME="Command Substitution">Command Substitution.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<DD></STRONG></FONT>The standard output from a command enclosed in parentheses preceded by
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortea dollar sign ( <STRONG>$( ) </STRONG>) or a pair of grave accents ( <STRONG><FONT SIZE=+1><SUB>`</SUB></FONT> <FONT SIZE=+1><SUB>`</SUB></FONT></STRONG> ) may be used as
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortepart or all of a word; trailing new-lines are removed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteIn the second (obsolete) form, the string between the quotes is processed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefor special quoting characters before the command is executed (see <A HREF="#Quoting"><EM>Quoting
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThe command substitution <STRONG>$( cat file )</STRONG> can be replaced by the equivalent
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortebut faster <STRONG>$( <file )</STRONG> .
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<H3><A NAME="Arithmetic Substitution">Arithmetic Substitution.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<DD></STRONG></FONT>An arithmetic expression enclosed in double parentheses preceded by a dollar
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesign ( <STRONG>$(( )) </STRONG>) is replaced by the value of the arithmetic expression within
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortethe double parentheses.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<H3><A NAME="Process Substitution">Process Substitution.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<DD></STRONG></FONT>This feature is only available on versions of the UNIX operating system
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortethat support the <STRONG>/dev/fd </STRONG>directory for naming open files.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteEach command argument of the form <STRONG><(</STRONG><EM>list </EM><STRONG>)</STRONG> or <STRONG>>(</STRONG><EM>list </EM><STRONG>)</STRONG> will run process
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<EM>list </EM>asynchronously connected to some file in <STRONG>/dev/fd</STRONG>.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThe name of this file will become the argument to the command.
0c034175550709323575bc82b80a835256239e86Jiri SvobodaIf the form with <STRONG>> </STRONG>is selected then writing on this file will provide input
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteIf <STRONG>< </STRONG>is used, then the file passed as an argument will contain the output
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortepaste <(cut -f1</STRONG> <EM>file1</EM><STRONG>) <(cut -f3</STRONG> <EM>file2</EM><STRONG>) | tee >(</STRONG><EM>process1</EM><STRONG>) >(</STRONG><EM>process2</EM><STRONG>)</STRONG><EM> </EM><EM><P>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefields 1 and 3 from the files <EM>file1 </EM>and <EM>file2 </EM>respectively, <EM>pastes </EM>the
0c034175550709323575bc82b80a835256239e86Jiri Svobodaresults together, and sends it to the processes <EM>process1 </EM>and <EM>process2</EM>,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteas well as putting it onto the standard output.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteNote that the file, which is passed as an argument to the command, is a
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteUNIX <EM>pipe</EM>(2) so programs that expect to <EM>lseek</EM>(2) on the file will not work.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<H3><A NAME="Parameter Expansion">Parameter Expansion.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<DD></STRONG></FONT>A <EM>parameter </EM>is a <EM>variable</EM>, one or more digits, or any of the characters
0c034175550709323575bc82b80a835256239e86Jiri Svoboda<STRONG>*</STRONG>, <STRONG>@</STRONG>, <STRONG>#</STRONG>, <STRONG>?</STRONG>, <STRONG>-</STRONG>, <STRONG>$</STRONG>, and <STRONG>! </STRONG>.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteA <EM>variable </EM>is denoted by a <EM>vname</EM>.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteTo create a variable whose <EM>vname </EM>contains a <STRONG><FONT SIZE=+1>.</FONT></STRONG>, a variable whose <EM>vname </EM>consists
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteof everything before the last <STRONG><FONT SIZE=+1>.</FONT></STRONG> must already exist.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteA <EM>variable </EM>has a <EM>value </EM>and zero or more <EM>attributes</EM>.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<EM>Variables </EM>can be assigned <EM>values </EM>and <EM>attributes </EM>by using the <STRONG>typeset </STRONG>special
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortebuilt-in command.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThe attributes supported by the shell are described later with the <STRONG>typeset
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte</STRONG>special built-in command.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteExported variables pass values and attributes to the environment.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThe shell supports both indexed and associative arrays.
0c034175550709323575bc82b80a835256239e86Jiri SvobodaAn element of an array variable is referenced by a <EM>subscript</EM>.
0c034175550709323575bc82b80a835256239e86Jiri SvobodaA <EM>subscript </EM>for an indexed array is denoted by an <EM>arithmetic expression
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte</EM>(see <A HREF="#Arithmetic Evaluation"><EM>Arithmetic Evaluation </EM></A>below) between a <STRONG>[ </STRONG>and a <STRONG>]</STRONG>.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteTo assign values to an indexed array, use <STRONG>set -A</STRONG> <EM>vname</EM> <EM>value</EM> . . .
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThe value of all subscripts must be in the range of 0 through 4095.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteIndexed arrays need not be declared.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteAny reference to a variable with a valid subscript is legal and an array
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortewill be created if necessary.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteAn associative array is created with the <STRONG>-A </STRONG>option to <STRONG>typeset.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte</STRONG>A <EM>subscript </EM>for an associative array is denoted by a string enclosed between
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteReferencing any array without a subscript is equivalent to referencing
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortethe array with subscript 0.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThe <EM>value </EM>of a <EM>variable </EM>may be assigned by writing: <DL COMPACT><EM><P>
0c034175550709323575bc82b80a835256239e86Jiri Svobodavname</EM><STRONG>=</STRONG><EM>value </EM>[ <EM>vname</EM><STRONG>=</STRONG><EM>value </EM> ] . . .
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevname</EM><STRONG>[</STRONG><EM>subscript</EM><STRONG>]=</STRONG><EM>value </EM>[ <EM>vname</EM><STRONG>[</STRONG><EM>subscript</EM><STRONG>]=</STRONG><EM>value </EM> ] . . .
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteNote that no space is allowed before or after the <STRONG>=</STRONG>.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteA <EM>nameref </EM>is a variable that is a reference to another variable.
0c034175550709323575bc82b80a835256239e86Jiri SvobodaA nameref is created with the <STRONG>-n </STRONG>attribute of <STRONG>typeset</STRONG>.
0c034175550709323575bc82b80a835256239e86Jiri SvobodaThe value of the variable at the time of the <STRONG>typeset </STRONG>command becomes the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevariable that will be referenced whenever the nameref variable is used.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThe name of a nameref cannot contain a <STRONG><FONT SIZE=+1>.</FONT></STRONG>.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteWhen a variable or function name contains a <STRONG><FONT SIZE=+1>.</FONT></STRONG>, and the portion of the name
0c034175550709323575bc82b80a835256239e86Jiri Svobodaup to the first <STRONG><FONT SIZE=+1>.</FONT></STRONG> matches the name of a nameref, the variable referred
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteto is obtained by replacing the nameref portion with the name of the variable
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortereferenced by the nameref.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteA nameref provides a convenient way to refer to the variable inside a function
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortewhose name is passed as an argument to a function.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteFor example, if the name of a variable is passed as the first argument
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteto a function, the command <DL COMPACT><STRONG><BR>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteinside the function causes references and assignments to <STRONG>var </STRONG>to be references
0c034175550709323575bc82b80a835256239e86Jiri Svobodaand assignments to the variable whose name has been passed to the function.
0c034175550709323575bc82b80a835256239e86Jiri SvobodaIf either of the floating point attributes, <STRONG>-E</STRONG>, or <STRONG>-F</STRONG>, or the integer attribute,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<STRONG>-i</STRONG>, is set for <EM>vname</EM>, then the <EM>value </EM>is subject to arithmetic evaluation
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteas described below.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortePositional parameters, parameters denoted by a number, may be assigned
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevalues with the <STRONG>set </STRONG>special built-in command.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteParameter <STRONG>$0 </STRONG>is set from argument zero when the shell is invoked.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThe character <STRONG>$ </STRONG>is used to introduce substitutable <EM>parameters</EM>.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte${</STRONG><EM>parameter </EM><STRONG>}</STRONG>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<DD>The shell reads all the characters from <STRONG>${ </STRONG>to the matching <STRONG>} </STRONG>as part of
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortethe same word even if it contains braces or metacharacters.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThe value, if any, of the parameter is substituted.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThe braces are required when <EM>parameter </EM>is followed by a letter, digit,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteor underscore that is not to be interpreted as part of its name, when the
0c034175550709323575bc82b80a835256239e86Jiri Svobodavariable name contains a <STRONG><FONT SIZE=+1>.</FONT></STRONG>, or when a variable is subscripted.
0c034175550709323575bc82b80a835256239e86Jiri SvobodaIf <EM>parameter </EM>is one or more digits then it is a positional parameter.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteA positional parameter of more than one digit must be enclosed in braces.
0c034175550709323575bc82b80a835256239e86Jiri SvobodaIf <EM>parameter </EM>is <STRONG>* </STRONG>or <STRONG>@</STRONG>, then all the positional parameters, starting with
0c034175550709323575bc82b80a835256239e86Jiri Svoboda<STRONG>$1</STRONG>, are substituted (separated by a field separator character).
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteIf an array <EM>vname </EM>with subscript <STRONG>* </STRONG>or <STRONG>@ </STRONG>is used, then the value for each
0c034175550709323575bc82b80a835256239e86Jiri Svobodaof the elements is substituted, separated by the first character of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte${#</STRONG><EM>parameter </EM><STRONG>}</STRONG>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<DD>If <EM>parameter </EM>is <STRONG>* </STRONG>or <STRONG>@</STRONG>, the number of positional parameters is substituted.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteOtherwise, the length of the value of the <EM>parameter </EM>is substituted.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte<DD>The number of elements in the array <EM>vname </EM>is substituted.
<DD></EM>Expands to name of the subscript unless <EM>subscript </EM>is <STRONG>* </STRONG>or <STRONG>@</STRONG>.
When <EM>subscript </EM>is <STRONG>*</STRONG>, the list of array subscripts for <EM>vname </EM> is generated.
When <EM>subscript </EM>is <STRONG>@</STRONG>, same as above, except that when used in double quotes,
<DD>If <EM>parameter </EM>is set and is non-null then substitute <EM>word</EM>; otherwise substitute
${</STRONG><EM>parameter </EM><STRONG>:</STRONG><EM>offset </EM><STRONG>:</STRONG><EM>length </EM><STRONG>}</STRONG>
(counting from <STRONG>0 </STRONG>) determined by expanding <EM>offset </EM>as an arithmetic expression
If <EM>parameter </EM>is <STRONG>* </STRONG>or <STRONG>@</STRONG>, or is an array name indexed by <STRONG>* </STRONG>or <STRONG>@</STRONG>, then <EM>offset
When <EM>parameter </EM>is <STRONG>@</STRONG>, <STRONG>*</STRONG>, or an array variable with subscript <STRONG>@ </STRONG>or <STRONG>*</STRONG>, the
When <EM>parameter </EM>is <STRONG>@</STRONG>, <STRONG>*</STRONG>, or an array variable with subscript <STRONG>@ </STRONG>or <STRONG>*</STRONG>, the
${</STRONG><EM>parameter </EM><STRONG>/</STRONG><EM>pattern </EM><STRONG>/</STRONG><EM>string </EM><STRONG>} </STRONG>
${</STRONG><EM>parameter </EM><STRONG>//</STRONG><EM>pattern </EM><STRONG>/</STRONG><EM>string </EM><STRONG>}
${</STRONG><EM>parameter </EM><STRONG>/#</STRONG><EM>pattern </EM><STRONG>/</STRONG><EM>string </EM><STRONG>}
${</STRONG><EM>parameter </EM><STRONG>/%</STRONG><EM>pattern </EM><STRONG>/</STRONG><EM>string </EM><STRONG>}
<DD></STRONG>Expands <EM>parameter </EM>and replaces the longest match of <EM>pattern </EM>with the given
</EM>Each occurrence of <STRONG>\</STRONG><EM>n </EM> in <EM>string </EM>is replaced by the portion of <EM>parameter </EM>
When <EM>string </EM>is null, the <EM>pattern </EM>will be deleted and the <STRONG>/ </STRONG>in front of
When <EM>parameter </EM>is <STRONG>@</STRONG>, <STRONG>*</STRONG>, or an array variable with subscript <STRONG>@ </STRONG>or <STRONG>*</STRONG>, the
string, so that, in the following example, <STRONG>pwd </STRONG>is executed only if <STRONG>d </STRONG>is
This parameter is also used to hold the name of the matching <STRONG><FONT SIZE=-1>MAIL </FONT></STRONG>file
entered when processing a <STRONG><FONT SIZE=-1>KEYBD </FONT></STRONG>trap (see <A HREF="#Key Bindings"><EM>Key Bindings </EM></A>below).
<DD>The value is set to ESC when processing a <STRONG><FONT SIZE=-1>KEYBD </FONT></STRONG>trap while in <STRONG>vi </STRONG>insert
(See <EM>Vi Editing Mode </EM>below.) Otherwise, <STRONG>.sh.edmode </STRONG>is null when processing
<DD>This variable is set by the <STRONG>select </STRONG>statement and by the <STRONG>read </STRONG>built-in command
<DD>If the value of this variable ends in <EM>emacs</EM>, <EM>gmacs</EM>, or <EM>vi </EM>and the <STRONG><FONT SIZE=-1>VISUAL
<STRONG><FONT SIZE=-1>FCEDIT </FONT></STRONG>is not used when <STRONG><FONT SIZE=-1>HISTEDIT </FONT></STRONG>is set.
<DD></FONT>Internal field separators, normally <STRONG>space</STRONG>, <STRONG>tab</STRONG>, and <STRONG>new-line </STRONG>that are used
The first character of the <FONT SIZE=-1><STRONG>IFS </STRONG></FONT>variable is used to separate arguments for
Each single occurrence of an <FONT SIZE=-1><STRONG>IFS </STRONG></FONT>character in the string to be split, that
<FONT SIZE=-1><STRONG>IFS </STRONG></FONT>that are in the <EM>isspace </EM> character class, delimit a field.
One or more characters in <FONT SIZE=-1><STRONG>IFS </STRONG></FONT>that belong to the <EM>isspace </EM> character class,
<FONT SIZE=-1><STRONG>IFS</STRONG>, </FONT>this character is treated as if it were not in the <EM>isspace </EM> class,
so that if <FONT SIZE=-1><STRONG>IFS </STRONG></FONT>consists of two <STRONG>tab </STRONG>characters, then two adjacent <STRONG>tab </STRONG>characters
selected with a variable starting with <STRONG><FONT SIZE=-1>LC_ </FONT></STRONG>or <FONT SIZE=-1><STRONG>LANG</STRONG>.
<DD>This variable overrides the value of the <STRONG><FONT SIZE=-1>LANG </FONT></STRONG>variable and any other <STRONG><FONT SIZE=-1>LC_
It determines the character classes for pattern matching (see <A HREF="#File Name Generation"><EM>File Name
Select lists will print vertically until about two-thirds of <STRONG><FONT SIZE=-1>LINES </FONT></STRONG>lines
<DD>If this variable is set to the name of a mail file <EM>and </EM>the <STRONG><FONT SIZE=-1>MAILPATH </FONT></STRONG>variable
changes in the modification time of any of the files specified by the <STRONG><FONT SIZE=-1>MAILPATH
to the specified files that have occurred within the last <STRONG><FONT SIZE=-1>MAILCHECK </FONT></STRONG>seconds.
The user may not change <STRONG><FONT SIZE=-1>PATH</FONT> </STRONG>if executing under <STRONG>rsh </STRONG>(except in <STRONG>.profile ).
Two successive occurrences of <STRONG>! </STRONG>will produce a single <STRONG>! </STRONG>when the prompt
<DD></FONT>Selection prompt string used within a <STRONG>select </STRONG>loop, by default ``<STRONG>#? </STRONG>''.
In addition when <FONT SIZE=-1><STRONG>PS4 </STRONG></FONT>is unset, the execution trace prompt is also ``<STRONG>+ </STRONG>''.
At invocation, if the basename of this variable is <STRONG>rsh</STRONG>, <STRONG>rksh</STRONG>, or <STRONG>krsh</STRONG>,
<DD>If set to a value greater than zero, <STRONG><FONT SIZE=-1>TMOUT </FONT></STRONG>will be the default timeout
The <STRONG>select </STRONG>compound command terminates after <STRONG><FONT SIZE=-1>TMOUT </FONT></STRONG>seconds when input is
<DD>If the value of this variable ends in <EM>emacs</EM>, <EM>gmacs</EM>, or <EM>vi </EM>then the corresponding
The value of <STRONG><FONT SIZE=-1>VISUAL </FONT></STRONG>overrides the value of <STRONG><FONT SIZE=-1>EDITOR.
The shell gives default values to <STRONG><FONT SIZE=-1>PATH</FONT></STRONG>, <STRONG><FONT SIZE=-1>PS1</FONT></STRONG>, <STRONG><FONT SIZE=-1>PS2</FONT></STRONG>, <STRONG><FONT SIZE=-1>PS3</FONT></STRONG>, <STRONG><FONT SIZE=-1>PS4</FONT></STRONG>, <STRONG><FONT SIZE=-1>MAILCHECK</FONT></STRONG>,
<STRONG><FONT SIZE=-1>FCEDIT</FONT></STRONG>, <STRONG><FONT SIZE=-1>TMOUT</FONT></STRONG> and <STRONG><FONT SIZE=-1>IFS</FONT></STRONG>, while <FONT SIZE=-1><STRONG>HOME</STRONG>, </FONT><FONT SIZE=-1><STRONG>SHELL</STRONG>, </FONT><FONT SIZE=-1><STRONG>ENV</STRONG>, </FONT>and <FONT SIZE=-1><STRONG>MAIL </STRONG></FONT>are not set at
all by the shell (although <FONT SIZE=-1><STRONG>HOME </STRONG></FONT><EM>is </EM>set by <EM>login</EM>(1)).
On some systems <FONT SIZE=-1><STRONG>MAIL </STRONG></FONT>and <FONT SIZE=-1><STRONG>SHELL </STRONG></FONT>are also set by <EM>login</EM>(1).
<DD></STRONG></FONT>After parameter expansion and command substitution, the results of substitutions
are scanned for the field separator characters (those found in <FONT SIZE=-1><STRONG>IFS </STRONG></FONT>) and
Explicit null fields ( <STRONG>" "</STRONG> or <STRONG>' '</STRONG> ) are retained.
<DD></STRONG></FONT>Following splitting, each field is scanned for the characters <STRONG>*</STRONG>, <STRONG>?</STRONG>, <STRONG>(</STRONG>,
If <FONT SIZE=-1><STRONG>FIGNORE </STRONG></FONT>is set, then each file name component that matches the pattern
defined by the value of <FONT SIZE=-1><STRONG>FIGNORE </STRONG></FONT>is ignored when generating the matching
If the first character following the opening <STRONG>[ </STRONG>is a <STRONG>! </STRONG>then any character
Within <STRONG>[ </STRONG>and <STRONG> ] </STRONG>, character classes can be specified with the syntax <STRONG>[:</STRONG><EM>class</EM><STRONG>:]</STRONG>
Within <STRONG>[ </STRONG>and <STRONG> ] </STRONG>, an equivalence class can be specified with the syntax
<STRONG>[=</STRONG><EM>c</EM><STRONG>=]</STRONG> which matches all characters with the same primary collation weight
Within <STRONG>[ </STRONG>and <STRONG> ] </STRONG>, <STRONG>[.</STRONG><EM>symbol</EM><STRONG>.]</STRONG> matches the collating symbol <EM>symbol</EM>.
A <STRONG>& </STRONG>signifies that all patterns must be matched whereas <STRONG>| </STRONG>requires that
The sequence <STRONG>\</STRONG><EM>n </EM>, where <EM>n </EM> is a single digit and <STRONG>\</STRONG><EM>n </EM> comes after the <EM>n</EM>-th.
<DD></STRONG></FONT>Each of the <EM>metacharacters </EM>listed earlier (see <A HREF="#Definitions"><EM>Definitions </EM></A>above) has a
All characters enclosed between a pair of single quote marks ( <STRONG>' '</STRONG> ) that
to be ignored and <STRONG>\E </STRONG>is equivalent to the escape character (ascii <STRONG>033</STRONG>).
and <STRONG>\ </STRONG>quotes the characters <STRONG>\</STRONG>, <STRONG><FONT SIZE=+1><SUB>`</SUB></FONT></STRONG>, <STRONG>"</STRONG>, and <STRONG>$</STRONG>.
The meaning of <STRONG>$* </STRONG>and <STRONG>$@ </STRONG>is identical when not quoted or when used as a
However, when used as a command argument, <STRONG>"$*" </STRONG>is equivalent to <STRONG>"$1</STRONG><EM>d</EM><STRONG> $2</STRONG><EM>d</EM> . . .<STRONG>"</STRONG>,
where <EM>d </EM>is the first character of the <FONT SIZE=-1><STRONG>IFS </STRONG></FONT>variable, whereas <STRONG>"$@" </STRONG>is equivalent
Inside grave quote marks (<STRONG><FONT SIZE=+1><SUB>`</SUB></FONT> <FONT SIZE=+1><SUB>`</SUB></FONT></STRONG>), <STRONG>\ </STRONG>quotes the characters <STRONG>\</STRONG>, <STRONG><FONT SIZE=+1><SUB>`</SUB></FONT></STRONG>, and <STRONG>$</STRONG>.
Integer constants are of the form [ <EM>base</EM><STRONG># </STRONG> ]<EM>n </EM> where <EM>base </EM>is a decimal
point can be specified with the <STRONG>-E</STRONG> [ <EM>n </EM> ] or <STRONG>-F</STRONG> [ <EM>n </EM> ] option of the <STRONG>typeset
the <STRONG>-i</STRONG> [ <EM>n </EM> ] option of the <STRONG>typeset </STRONG>special built-in command.
variable with the <STRONG>-E</STRONG>, <STRONG>-F</STRONG>, or <STRONG>-i </STRONG>attribute.
<DD></STRONG></FONT>When used interactively, the shell prompts with the value of <FONT SIZE=-1><STRONG>PS1 </STRONG></FONT>after
a command, then the secondary prompt (i.e., the value of <STRONG><FONT SIZE=-1>PS2</FONT></STRONG>) is issued.
<DD></STRONG></FONT>A <EM>conditional expression </EM>is used with the <STRONG>[[ </STRONG>compound command to test attributes
<DD>True, if <EM>file1 </EM>exists and <EM>file2 </EM>does not, or <EM>file1 </EM>is newer than <EM>file2</EM>.
<DD>True, if <EM>file2 </EM>exists and <EM>file1 </EM>does not, or <EM>file1 </EM>is older than <EM>file2</EM>.
<DD>True, if <EM>string1 </EM>comes before <EM>string2 </EM>based on ASCII value of their characters.
<DD>True, if <EM>string1 </EM>comes after <EM>string2 </EM>based on ASCII value of their characters.
In each of the above expressions, if <EM>file </EM>is of the form <STRONG>/dev/fd/</STRONG><EM>n</EM>, where
In each of the following redirections, if <EM>file </EM>is of the form <STRONG>/dev/tcp/</STRONG><EM>host</EM><STRONG>/</STRONG><EM>port</EM>,
or <STRONG>/dev/udp/</STRONG><EM>host</EM><STRONG>/</STRONG><EM>port</EM>, where <EM>host </EM>is a hostname or host address, and <EM>port
and <STRONG>\ </STRONG>must be used to quote the characters <STRONG>\</STRONG>, <STRONG>$</STRONG>, <STRONG><FONT SIZE=+1><SUB>`</SUB></FONT></STRONG>.
If <STRONG>- </STRONG>is appended to <STRONG><<</STRONG>, then all leading tabs are stripped from <EM>word </EM>and
<DD>The standard input is duplicated from file descriptor <EM>digit </EM>(see <A HREF="dup(2)"><EM>dup</EM>(2)</A>).
Similarly for the standard output using <STRONG>>& </STRONG><EM>digit</EM><STRONG>-</STRONG>.
descriptor 1 (i.e.
<DD></STRONG></FONT>The <EM>environment </EM>(see <A HREF="environ(7)"><EM>environ</EM>(7)</A>) is a list of name-value pairs that is
using the <STRONG>export </STRONG>or <STRONG>typeset -x </STRONG>commands, they become part of the environment.
(export <FONT SIZE=-1>TERM</FONT>; <FONT SIZE=-1>TERM</FONT>=450; cmd args)</STRONG> </DL>
If the obsolete <STRONG>-k </STRONG>option is set, <EM>all </EM>variable assignment arguments are
<DD></STRONG></FONT>For historical reasons, there are two ways to define functions, the <EM>name</EM><STRONG>( )
</STRONG>syntax and the <STRONG>function </STRONG><EM>name </EM>syntax, described in the <EM>Commands </EM>section
A trap on <FONT SIZE=-1><STRONG>EXIT </STRONG></FONT>set inside a function is executed in the environment of
Functions defined with the <EM>name</EM><STRONG>( ) </STRONG>syntax and functions defined with the
<STRONG>function </STRONG><EM>name </EM>syntax that are invoked with the <STRONG><FONT SIZE=+1>.</FONT></STRONG> special built-in are executed
Function names can be listed with the <STRONG>-f </STRONG>or <STRONG>+f </STRONG>option of the <STRONG>typeset </STRONG>special
Functions can be undefined with the <STRONG>-f </STRONG>option of the <STRONG>unset </STRONG>special built-in
should be placed in a directory and the <STRONG><FONT SIZE=-1>FPATH </FONT></STRONG>variable should contain the
The shell initially understands the discipline names <STRONG>get</STRONG>, <STRONG>set</STRONG>, and <STRONG>unset</STRONG>
<STRONG>.sh.value </STRONG>will contain the value being assigned inside the <STRONG>.set </STRONG>discipline
For the <STRONG>set</STRONG> discipline, changing <STRONG>.sh.value </STRONG>will change the value that gets
<DD></STRONG></FONT>If the <STRONG>monitor </STRONG>option of the <STRONG>set </STRONG>command is turned on, an interactive shell
The <STRONG>notify </STRONG>option of the <STRONG>set </STRONG>command causes the shell to print these job
<DD></STRONG></FONT>The <FONT SIZE=-1>INT</FONT> and <FONT SIZE=-1>QUIT</FONT> signals for an invoked command are ignored if the command
For functions defined with the <STRONG>function </STRONG><EM>name </EM>syntax, any trap set on <FONT SIZE=-1><STRONG>EXIT
The shell variable <STRONG><FONT SIZE=-1>PATH </FONT></STRONG>defines the search path for the directory containing
The default path is <STRONG>/bin:/usr/bin: </STRONG>(specifying <STRONG>/bin</STRONG>, <STRONG>/usr/bin</STRONG>, and the
<DD></STRONG></FONT>The text of the last <STRONG><FONT SIZE=-1>HISTSIZE </FONT></STRONG>(default 128) commands entered from a terminal
The file <STRONG><FONT SIZE=-1>$HOME</FONT>/.sh_history </STRONG>is used if the <STRONG><FONT SIZE=-1>HISTFILE </FONT></STRONG>variable is not set
If <FONT SIZE=-1><STRONG>HISTEDIT </STRONG></FONT>is unset, the obsolete variable <FONT SIZE=-1><STRONG>FCEDIT </STRONG></FONT>is used.
If <FONT SIZE=-1><STRONG>FCEDIT </STRONG></FONT>is not defined, then <STRONG>/bin/ed </STRONG>is used.
The <STRONG>-s </STRONG>option (and in obsolete versions, the editor name <STRONG>- </STRONG>) is used to
In this case a substitution parameter of the form <EM>old</EM><STRONG>=</STRONG><EM>new</EM> can be used to
For example, with the preset alias <STRONG>r</STRONG>, which is aliased to <STRONG>'hist -s'</STRONG>, typing
the letter <STRONG>c</STRONG>, replacing the first occurrence of the string <STRONG>bad </STRONG>with the
If either the <STRONG>emacs</STRONG>, <STRONG>gmacs</STRONG>, or <STRONG>vi </STRONG>option is active, the user can edit the
An editing option is automatically selected each time the <FONT SIZE=-1><STRONG>VISUAL </STRONG></FONT>or <FONT SIZE=-1><STRONG>EDITOR
The window width is the value of <FONT SIZE=-1><STRONG>COLUMNS </STRONG></FONT>if it is defined, otherwise 80.
The mark is a <STRONG>></STRONG> (<<STRONG>, </STRONG><STRONG>*</STRONG>) if the line extends on the right (left, both) side(s)
<STRONG>|</STRONG>, <STRONG>&</STRONG>, or <STRONG>(</STRONG>, and the word does not begin with <STRONG>~ </STRONG>or contain a <STRONG>/</STRONG>, the list
of aliases, functions, and executable commands defined by the <STRONG><FONT SIZE=-1>PATH </FONT></STRONG>variable
<DD></STRONG></FONT>The <STRONG><FONT SIZE=-1>KEYBD </FONT></STRONG>trap can be used to intercept keys as they are typed and change
The variable <STRONG>.sh.edmode </STRONG>is set to ESC when in <STRONG>vi </STRONG>insert mode (see below)
By prepending <STRONG>${.sh.editmode} </STRONG>to a value assigned to <STRONG>.sh.edchar </STRONG>it will
<DD></STRONG></FONT>This mode is entered by enabling either the <STRONG>emacs </STRONG>or <STRONG>gmacs </STRONG>option.
The commands that accept a parameter are <STRONG>^F</STRONG>, <STRONG>^B</STRONG>, <EM>erase</EM>, <STRONG>^C</STRONG>, <STRONG>^D</STRONG>, <STRONG>^K</STRONG>, <STRONG>^R</STRONG>,
<STRONG>^P</STRONG>, <STRONG>^N</STRONG>, <STRONG>^]</STRONG>, <STRONG>M-.</STRONG>, <STRONG>M-^]</STRONG>, <STRONG>M-_</STRONG>, <STRONG>M-b</STRONG>, <STRONG>M-c</STRONG>, <STRONG>M-d</STRONG>, <STRONG>M-f</STRONG>, <STRONG>M-h</STRONG>, <STRONG>M-l </STRONG>and <STRONG>M-^H</STRONG>.
<DD>Soft-key - Your alias list is searched for an alias by the name <STRONG>_</STRONG><EM>letter
<DD>Soft-key - Your alias list is searched for an alias by the name <STRONG>__</STRONG><EM>letter
<DD>If the line does not begin with a <STRONG>#</STRONG>, a <STRONG># </STRONG>is inserted at the beginning of
If the line begins with a <STRONG>#</STRONG>, the <STRONG># </STRONG>is deleted and one <STRONG># </STRONG>after each new-line
<H3><A NAME="Input Edit Commands"> Input Edit Commands </A></H3>
<H3><A NAME="Motion Edit Commands"> Motion Edit Commands </A></H3>
<DD>Repeats <EM>count </EM>times, the last single character find command, <STRONG>f</STRONG>, <STRONG>F</STRONG>, <STRONG>t</STRONG>, or
<DD>Moves to balancing <STRONG>(</STRONG>, <STRONG>)</STRONG>, <STRONG>{</STRONG>, <STRONG>}</STRONG>, <STRONG>[</STRONG>, or <STRONG>]</STRONG>.
<H3><A NAME="Search Edit Commands"> Search Edit Commands </A></H3>
<DD>Search for next match of the last pattern to <STRONG>/ </STRONG>or <STRONG>?</STRONG>, but in reverse direction.
<H3><A NAME="Text Modification Edit Commands"> Text Modification Edit Commands </A></H3>
<H3><A NAME="Other Edit Commands"> Other Edit Commands </A></H3>
<DD>Returns the command <STRONG>hist -e ${<FONT SIZE=-1>VISUAL</FONT>:-${<FONT SIZE=-1>EDITOR</FONT>:-vi}}</STRONG><EM> count </EM>in the input
<DD>Your alias list is searched for an alias by the name <STRONG>_</STRONG><EM>letter </EM>and if an
Except for <STRONG>:</STRONG>, <STRONG>true</STRONG>, <STRONG>false</STRONG>, <STRONG>echo</STRONG>, <STRONG>command</STRONG>, <STRONG>newgrp</STRONG>, and <STRONG>login</STRONG>, all built-in
They also interpret the option <STRONG>-? </STRONG>as a help request and print a <EM>usage </EM>message
<DD></STRONG>If <EM>name </EM>is a function defined with the <STRONG>function </STRONG><EM>name </EM>reserved word syntax,
defined with the <EM>name</EM><STRONG>() </STRONG>syntax.) Otherwise if <EM>name </EM>refers to a file, the
The search path specified by <STRONG><FONT SIZE=-1>PATH </FONT></STRONG>is used to find the directory containing
§§ <STRONG>alias</STRONG> [ <STRONG>-ptx</STRONG> ] [ <EM>name</EM>[ <STRONG>=</STRONG><EM>value </EM> ] ]. . .
The <STRONG>-p </STRONG>option causes the word <STRONG>alias </STRONG>to be inserted before each one.
The value becomes undefined when the value of <FONT SIZE=-1><STRONG>PATH </STRONG></FONT>is reset but the alias
Without the <STRONG>-t </STRONG>option, for each <EM>name </EM>in the argument list for which no
<DD>Exit from the enclosing <STRONG>for </STRONG>, <STRONG>while </STRONG>, <STRONG>until </STRONG>, or <STRONG>select </STRONG>loop, if any.
builtin</STRONG> [ <STRONG>-ds</STRONG> ] [ <STRONG>-f</STRONG> <EM>file </EM> ][ <EM>name </EM>. . . ]
<DD>If <EM>name </EM>is not specified, and no <STRONG>-f </STRONG>option is specified, the built-ins
name is <STRONG>lib_init() </STRONG>and invokes this function with an argument of <STRONG>0</STRONG>.
The shell variable <STRONG><FONT SIZE=-1>CDPATH </FONT></STRONG>defines the search path for the directory containing
The second form of <STRONG>cd </STRONG>substitutes the string <EM>new </EM>for the string <EM>old </EM>in
the current directory name, <FONT SIZE=-1><STRONG>PWD</STRONG>, </FONT>and tries to change to this new directory.
The last instance of <STRONG>-L </STRONG>or <STRONG>-P </STRONG>on the command line determines which method
command</STRONG> [ <STRONG>-pvV</STRONG> ] <EM>name </EM> [ <EM>arg </EM> . . . ]
<DD>Without the <STRONG>-v </STRONG>or <STRONG>-V </STRONG>options, <STRONG>command </STRONG>executes <EM>name </EM>with the arguments
<STRONG>command </STRONG>is equivalent to the built-in <STRONG>whence </STRONG>command described below.
The <STRONG>-V </STRONG>option causes <STRONG>command </STRONG>to act like <STRONG>whence -v</STRONG>.
<DD>Resume the next iteration of the enclosing <STRONG>for </STRONG>, <STRONG>while </STRONG>, <STRONG>until </STRONG>, or <STRONG>select
a \, then <STRONG>echo </STRONG>prints each of its arguments separated by a space and terminated
Otherwise, the behavior of <STRONG>echo </STRONG>is system dependent and <STRONG>print </STRONG>or <STRONG>printf
§ <STRONG>exec</STRONG> [ <STRONG>-c</STRONG> ] [ <STRONG>-a</STRONG> <EM>name </EM> ][ <EM>arg </EM>. . . ]
The <STRONG>-a </STRONG>option causes <EM>name </EM>rather than the first <EM>arg</EM>, to become <STRONG>argv[0]
has the <STRONG>ignoreeof </STRONG>option (see <A HREF="#set"><STRONG>set </STRONG></A>below) turned on.
§§ <STRONG>export</STRONG> [ <STRONG>-p</STRONG> ] [ <EM>name </EM>[ <STRONG>=</STRONG><EM>value </EM> ] ]. . .
The <STRONG>-p </STRONG>option causes the word <STRONG>export </STRONG>to be inserted before each one.
getopts</STRONG> [ <STRONG> -a</STRONG> <EM>name </EM> ] <EM>optstring vname </EM> [ <EM>arg </EM>. . . ]
An option not beginning with <STRONG>+ </STRONG>or <STRONG>- </STRONG>or the argument <STRONG>- - </STRONG>ends the options.
The option <STRONG>-? </STRONG>causes <STRONG>getopts </STRONG>to generate a usage message on standard error.
The option letter will be prepended with a <STRONG>+ </STRONG>when <EM>arg </EM>begins with a <STRONG>+</STRONG>.
A leading <STRONG>: </STRONG>in <EM>optstring </EM>causes <STRONG>getopts </STRONG>to store the letter of an invalid
option in <FONT SIZE=-1><STRONG>OPTARG</STRONG>, </FONT>and to set <EM>vname </EM>to <STRONG>? </STRONG>for an unknown option and to <STRONG>:
There is no way to specify any of the options <STRONG>:</STRONG>, <STRONG>+</STRONG>, <STRONG>-</STRONG>, <STRONG>?</STRONG>, <STRONG>[</STRONG>, and <STRONG>]</STRONG>.
hist</STRONG> [ <STRONG>-e</STRONG> <EM>ename </EM> ] [ <STRONG>-nlr </STRONG> ][ <EM>first </EM>[ <EM>last </EM> ] ]
hist -s </STRONG> [ <EM>old</EM><STRONG>=</STRONG><EM>new </EM> ] [ <EM>command </EM> ]
If <EM>ename </EM>is not supplied, then the value of the variable <FONT SIZE=-1><STRONG>HISTEDIT </STRONG></FONT>is used.
If <FONT SIZE=-1><STRONG>HISTEDIT </STRONG></FONT>is not set, then <FONT SIZE=-1><STRONG>FCEDIT </STRONG></FONT>(default <STRONG>/bin/ed </STRONG>) is used as the editor.
The option <STRONG>-r </STRONG>reverses the order of the commands and the option <STRONG>-n </STRONG>suppresses
The resulting command is executed after the optional substitution <EM>old </EM><STRONG>=</STRONG><EM>new </EM>
jobs</STRONG> [ <STRONG>-lnp </STRONG> ] [ <EM>job </EM> . . .
kill</STRONG> [ <STRONG>-s</STRONG> <EM>signame </EM> ] <EM>job </EM> . . .
kill</STRONG> [ <STRONG>-n</STRONG> <EM>signum </EM> ] <EM>job </EM> . . .
<STRONG>-s </STRONG>option (as given in <STRONG><signal.h></STRONG>, stripped of the prefix ``SIG'' with
For backward compatibility, the <STRONG>n </STRONG>and <STRONG>s </STRONG>can be omitted and the number or
In the third form, <STRONG>kill -l</STRONG>, if <EM>sig </EM>is not specified, the signal names are
print</STRONG> [ <STRONG>-Rnprs </STRONG> ] [ <STRONG>-u</STRONG> <EM>unit </EM> ] [ <STRONG>-f</STRONG><EM>format </EM> ][ <EM>arg </EM>. . . ]
<DD>With no options or with option <STRONG>- </STRONG>or <STRONG>- -</STRONG>, each <EM>arg </EM>is printed on standard
The <STRONG>-f </STRONG>option causes the arguments to be printed as described by <STRONG>printf</STRONG>.
Otherwise, unless the <STRONG>-R </STRONG>or <STRONG>-r</STRONG>, are specified, the following escape conventions
If the option <STRONG>-n </STRONG>is used, no <STRONG>new-line </STRONG>is added to the output.
<DD>A <STRONG>%b </STRONG>format can be used instead of <STRONG>%s </STRONG>to cause escape sequences in the
<DD>A <STRONG>%P </STRONG>format can be used instead of <STRONG>%s </STRONG>to cause <EM>arg </EM>to be interpreted as
<DD>A <STRONG>%q </STRONG>format can be used instead of <STRONG>%s </STRONG>to cause the resulting string to
The last instance of <STRONG>-L </STRONG>or <STRONG>-P </STRONG>on the command line determines which method
read</STRONG> [ <STRONG>-Aprs </STRONG> ] [ <STRONG>-d</STRONG> <EM>delim </EM> ] [ <STRONG>-t</STRONG><EM>timeout </EM> ][ <STRONG>-u</STRONG><EM>unit </EM> ][ <EM>vname</EM><STRONG>?</STRONG><EM>prompt </EM><STRONG> ][ </STRONG><EM>vname </EM><STRONG>. . . ]
In raw mode, <STRONG>-r, </STRONG>the <STRONG>\ </STRONG>character is not treated specially.
The <STRONG>-A </STRONG>option causes the variable <EM>vname </EM>to be unset and each field that
The option <STRONG>-u </STRONG>can be used to specify a one digit file descriptor unit <EM>unit
If <EM>vname </EM>is omitted, then <FONT SIZE=-1><STRONG>REPLY </STRONG></FONT>is used as the default <EM>vname</EM>.
§§ <STRONG>readonly</STRONG> [ <STRONG>-p</STRONG> ] [ <EM>vname</EM>[ <STRONG>=</STRONG><EM>value </EM> ] ]. . .
The <STRONG>-p </STRONG>option causes the word <STRONG>readonly </STRONG>to be inserted before each one.
<DD>Causes a shell <EM>function </EM>or <STRONG> .</STRONG> script to return to the invoking script with
If <STRONG>return </STRONG>is invoked while not in a <EM>function </EM>or a <STRONG> .</STRONG> script, then it behaves
§ <STRONG><A NAME="set">set</A></STRONG>[ <STRONG>±Cabefhkmnopstuvx</STRONG> ] [ <STRONG>±o</STRONG> [ <EM>option </EM> ] ]. . .[ <STRONG>±A</STRONG><EM>vname </EM> ][ <EM>arg </EM>. . . ]
<DD>If a command has a non-zero exit status, execute the <FONT SIZE=-1><STRONG>ERR </STRONG></FONT>trap, if set,
<DD>Disables processing of the <STRONG><FONT SIZE=-1>$HOME</FONT>/.profile </STRONG>file and uses the file <STRONG>/etc/suid_profile
As an obsolete feature, if the first <EM>arg </EM>is <STRONG>- </STRONG>then the <STRONG>-x </STRONG>and <STRONG>-v </STRONG>options
§ <STRONG>trap'</STRONG> [ <STRONG>-p</STRONG> ] [ <EM>action </EM> ][ <EM>sig </EM> ]. . .
<DD>The <STRONG>-p </STRONG>option causes the trap action associated with each trap as specified
Otherwise, <EM>action </EM>will be processed as if it were an argument to <STRONG>eval </STRONG>when
If <EM>action </EM>is omitted and the first <EM>sig </EM>is a number, or if <EM>action </EM>is <STRONG>-</STRONG>,
If <EM>sig </EM>is <FONT SIZE=-1><STRONG>ERR </STRONG></FONT>then <EM>action </EM>will be executed whenever a command has a non-zero
If <EM>sig </EM>is <FONT SIZE=-1><STRONG>DEBUG </STRONG></FONT>then <EM>action </EM>will be executed before each command.
If <EM>sig </EM>is <STRONG>0 </STRONG>or <FONT SIZE=-1><STRONG>EXIT </STRONG></FONT>and the <STRONG>trap </STRONG>statement is executed inside the body
If <EM>sig </EM>is <STRONG>0 </STRONG>or <FONT SIZE=-1><STRONG>EXIT </STRONG></FONT>for a <STRONG>trap </STRONG>set outside any function then the command
If <EM>sig </EM>is <FONT SIZE=-1><STRONG>KEYBD</STRONG>, </FONT>then <EM>action </EM>will be executed whenever a key is read while
§§ <STRONG>typeset</STRONG> [ <STRONG>±AHflnprtux </STRONG> ] [ <STRONG>±EFLRZi[ </STRONG><EM>n </EM><STRONG> ] ][ </STRONG><EM>vname </EM><STRONG>[ =</STRONG><EM>value </EM><STRONG> ] ]. . .
No assignments can be made and the only other valid options are <STRONG>-t</STRONG>, <STRONG>-u
The <FONT SIZE=-1><STRONG>FPATH </STRONG></FONT>variable will be searched to find the function definition when
The <STRONG>-i </STRONG>attribute cannot be specified along with <STRONG>-R</STRONG>, <STRONG>-L</STRONG>, <STRONG>-Z</STRONG>, or <STRONG>-f</STRONG>.
If no <EM>vname </EM>arguments are given, a list of <EM>vnames </EM>(and optionally the <EM>values </EM>)
(Using <STRONG>+ </STRONG>rather than <STRONG>- </STRONG>keeps the values from being printed.) The <STRONG>-p </STRONG>option
ulimit</STRONG> [ <STRONG>-HSacdfmnpstv</STRONG> ] [ <EM>limit </EM> ]
The <STRONG>-H </STRONG>and <STRONG>-S </STRONG>options specify whether the hard limit or the soft limit
If neither the <STRONG>H </STRONG>nor <STRONG>S </STRONG>options is specified, the limit applies to both.
<DD>The user file-creation mask is set to <EM>mask </EM>(see <A HREF="umask(2)"><EM>umask</EM>(2)</A>).
§ <STRONG>unalias</STRONG> [ <STRONG>-a</STRONG> ] <EM>name </EM> . . .
§<STRONG>unset</STRONG> [ <STRONG>-fnv</STRONG> ] <EM>vname </EM> . . .
If <STRONG>-n </STRONG>is set and <EM>name </EM>is a name reference, then <EM>name </EM>will be unset rather
Unsetting <FONT SIZE=-1><STRONG>LINENO</STRONG>, </FONT><FONT SIZE=-1><STRONG>MAILCHECK</STRONG>, </FONT><FONT SIZE=-1><STRONG>OPTARG</STRONG>, </FONT><FONT SIZE=-1><STRONG>OPTIND</STRONG>, </FONT><FONT SIZE=-1><STRONG>RANDOM</STRONG>, </FONT><FONT SIZE=-1><STRONG>SECONDS</STRONG>, </FONT><FONT SIZE=-1><STRONG>TMOUT</STRONG>, </FONT>and
<FONT SIZE=-1><STRONG>_ </STRONG></FONT>removes their special meaning even if they are subsequently assigned
The <STRONG>-p </STRONG>option does a path search for <EM>name </EM>even if name is an alias, a function,
The <STRONG>-a </STRONG>option is similar to the <STRONG>-v </STRONG>option but causes all interpretations
<DD></STRONG></FONT>If the shell is invoked by <EM>exec</EM>(2), and the first character of argument
zero (<STRONG>$0</STRONG>) is <STRONG>-</STRONG>, then the shell is assumed to be a <EM>login </EM>shell and commands
are read from <STRONG>/etc/profile </STRONG>and then from either <STRONG>.profile </STRONG>in the current
on the value of the environment variable <FONT SIZE=-1><STRONG>ENV </STRONG></FONT>if the file exists.
If the <STRONG>-s </STRONG>option is not present and <EM>arg </EM>is, then a path search is performed
The script <EM>arg </EM>must have read permission and any <EM>setuid </EM>and <EM>setgid </EM>settings
<DD>If the <STRONG>-c </STRONG>option is present, then commands are read from the first <EM>arg</EM>.
In this case <FONT SIZE=-1>TERM</FONT> is ignored (so that <STRONG>kill 0</STRONG> does not kill an interactive
shell) and <FONT SIZE=-1>INTR</FONT> is caught and ignored (so that <STRONG>wait </STRONG>is interruptible).
<DD>The <STRONG>-R </STRONG><EM>filename </EM>option is used to generate a cross reference database that
<DD></STRONG></FONT><EM>Rsh </EM>is used to set up login names and execution environments whose capabilities
The actions of <STRONG>rsh </STRONG>are identical to those of <STRONG>sh </STRONG>, except that the following
setting or unsetting the value or attributes of <FONT SIZE=-1><STRONG>SHELL</STRONG>, </FONT><FONT SIZE=-1><STRONG>ENV</STRONG>, </FONT>or <FONT SIZE=-1><STRONG>PATH</STRONG></FONT><FONT SIZE=-2>0, </FONT><BR>
redirecting output (<STRONG>></STRONG>, <STRONG>>|</STRONG>, <STRONG><></STRONG>, and <STRONG>>></STRONG>).
The restrictions above are enforced after <STRONG>.profile</STRONG> and the <FONT SIZE=-1><STRONG>ENV </STRONG></FONT>files are
<DD></STRONG></FONT>cat(1), cd(1), chmod(1), cut(1), echo(1), emacs(1), env(1), gmacs(1), newgrp(1),
wait(2), rand(3), a.out(5), profile(5), environ(7).
Use the <STRONG>-t </STRONG>option of the <STRONG>alias </STRONG>command to correct this situation.
The built-in command <STRONG> .</STRONG> <EM>file </EM> reads the whole file before any commands
Therefore, <STRONG>alias </STRONG>and <STRONG>unalias </STRONG>commands in the file will not apply to any