Sophie

Sophie

distrib > Mandriva > 9.1 > i586 > by-pkgid > 0195c26144d6a6d8437da6bf9d0aeff3 > files > 55

zsh-doc-4.1.0-0.dev5.4mdk.i586.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                      "http://www.w3.org/TR/html40/loose.dtd">
<HTML>
<!-- Created on August, 9 2002 by texi2html 1.65 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
            Karl Berry  <karl@freefriends.org>
            Olaf Bachmann <obachman@mathematik.uni-kl.de>
            and many others.
Maintained by: Olaf Bachmann <obachman@mathematik.uni-kl.de>
Send bugs and suggestions to <texi2html@mathematik.uni-kl.de>

-->
<HEAD>
<TITLE>zsh: Expansion</TITLE>

<META NAME="description" CONTENT="zsh: Expansion">
<META NAME="keywords" CONTENT="zsh: Expansion">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<META NAME="Generator" CONTENT="texi2html 1.65">

</HEAD>

<BODY LANG="en" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000">

<A NAME="SEC40"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_12.html#SEC39"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC41"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_12.html#SEC39"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh.html#SEC_Top"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_14.html#SEC63"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_24.html#SEC195">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H1> 13. Expansion </H1>
<!--docid::SEC40::-->
<A NAME="IDX134"></A>
<P>

The following types of expansions are performed in the indicated order in
five steps:
</P>
<P>

</P>
<DL COMPACT>
<DT><EM>History Expansion</EM>
<DD>This is performed only in interactive shells.
<P>

</P>
<DT><EM>Alias Expansion</EM>
<DD>Aliases are expanded immediately before the command line is parsed as
explained
in <A HREF="zsh_5.html#SEC25">5.7 Aliasing</A>.
<P>

</P>
<DT><EM>Process Substitution</EM>
<DD><DT><EM>Parameter Expansion</EM>
<DD><DT><EM>Command Substitution</EM>
<DD><DT><EM>Arithmetic Expansion</EM>
<DD><DT><EM>Brace Expansion</EM>
<DD>These five are performed in one step in left-to-right fashion.  After
these expansions, all unquoted occurrences of the characters `<TT>\</TT>',
`<TT>'</TT>' and `<TT>&quot;</TT>' are removed.
<P>

</P>
<DT><EM>Filename Expansion</EM>
<DD>If the <TT>SH_FILE_EXPANSION</TT> option is set, the order of expansion is
modified for compatibility with <CITE>sh</CITE> and <CITE>ksh</CITE>.  In that case
<EM>filename expansion</EM> is performed immediately after <EM>alias expansion</EM>,
preceding the set of five expansions mentioned above.
<P>

<A NAME="IDX135"></A>
</P>
<DT><EM>Filename Generation</EM>
<DD>This expansion, commonly referred to as <CITE>globbing</CITE>, is always done last.
<P>

</DL>
<P>

The following sections explain the types of expansion in detail.
</P>
<P>

<TABLE BORDER="0" CELLSPACING="0">
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="zsh_13.html#SEC41">13.1 History Expansion</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="zsh_13.html#SEC46">13.2 Process Substitution</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="zsh_13.html#SEC47">13.3 Parameter Expansion</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="zsh_13.html#SEC51">13.4 Command Substitution</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="zsh_13.html#SEC52">13.5 Arithmetic Expansion</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="zsh_13.html#SEC53">13.6 Brace Expansion</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="zsh_13.html#SEC54">13.7 Filename Expansion</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="zsh_13.html#SEC55">13.8 Filename Generation</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
</TABLE>
<A NAME="History Expansion"></A>
<P>

<HR SIZE="6">
<A NAME="SEC41"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC40"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC42"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC40"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC40"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_14.html#SEC63"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_24.html#SEC195">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 13.1 History Expansion </H2>
<!--docid::SEC41::-->
<A NAME="IDX136"></A>
<A NAME="IDX137"></A>
<A NAME="IDX138"></A>
History expansion allows you to use words from previous command
lines in the command line you are typing.  This simplifies spelling
corrections and the repetition of complicated commands or arguments.
<A NAME="IDX139"></A>
Immediately before execution, each command is saved in the history list,
the size of which is controlled by the <TT>HISTSIZE</TT> parameter.  The one
most recent command is always retained in any case.  Each saved command in
the history list is called a history <EM>event</EM> and is assigned a number,
beginning with 1 (one) when the shell starts up.  The history number that
you may see in your prompt (see
<A HREF="zsh_12.html#SEC39">12. Prompt Expansion</A>) is the number that is to be assigned to the <EM>next</EM> command.
<P>

<TABLE BORDER="0" CELLSPACING="0">
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="zsh_13.html#SEC42">13.1.1 Overview</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="zsh_13.html#SEC43">13.1.2 Event Designators</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="zsh_13.html#SEC44">13.1.3 Word Designators</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="zsh_13.html#SEC45">13.1.4 Modifiers</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
</TABLE>
<A NAME="Overview"></A>
<P>

<HR SIZE="6">
<A NAME="SEC42"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC41"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC43"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC40"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC41"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_14.html#SEC63"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_24.html#SEC195">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 13.1.1 Overview </H3>
<!--docid::SEC42::-->
<A NAME="IDX140"></A>
A history expansion begins with the first character of the <TT>histchars</TT>
parameter, which is `<TT>!</TT>' by default, and may occur anywhere on the
command line; history expansions do not nest.  The `<TT>!</TT>' can be escaped
with `<TT>\</TT>' or can be enclosed between a pair of single quotes (<TT>&quot;</TT>)
to suppress its special meaning.  Double quotes will <EM>not</EM> work for
this.  Following this history character is an optional event designator
(<A HREF="zsh_13.html#SEC43">13.1.2 Event Designators</A>) and then an optional word
designator (<A HREF="zsh_13.html#SEC44">13.1.3 Word Designators</A>); if neither of these designators is
present, no history expansion occurs.
<P>

Input lines containing history expansions are echoed after being expanded,
but before any other expansions take place and before the command is
executed.  It is this expanded form that is recorded as the history event
for later references.
</P>
<P>

By default, a history reference with no event designator refers to the
same event as any preceding history reference on that command line; if it
is the only history reference in a command, it refers to the previous
command.
<A NAME="IDX141"></A>
However, if the option <TT>CSH_JUNKIE_HISTORY</TT> is set, then every history
reference with no event specification <EM>always</EM> refers to the previous
command.
</P>
<P>

For example, `<TT>!</TT>' is the event designator for the previous command, so
`<TT>!!:1</TT>' always refers to the first word of the previous command, and
`<TT>!!$</TT>' always refers to the last word of the previous command.  With
<TT>CSH_JUNKIE_HISTORY</TT> set, then `<TT>!:1</TT>' and `<TT>!$</TT>' function in the
same manner as `<TT>!!:1</TT>' and `<TT>!!$</TT>', respectively.  Conversely, if
<TT>CSH_JUNKIE_HISTORY</TT> is unset, then `<TT>!:1</TT>' and `<TT>!$</TT>' refer to the
first and last words, respectively, of the same event referenced by the
nearest other history reference preceding them on the current command
line, or to the previous command if there is no preceding reference.
</P>
<P>

The character sequence `<TT>^</TT><VAR>foo</VAR><TT>^</TT><VAR>bar</VAR>' (where `<TT>^</TT>' is
actually the second character of the <TT>histchars</TT> parameter)
repeats the last command, replacing the string <VAR>foo</VAR> with <VAR>bar</VAR>.
More precisely, the sequence `<TT>^</TT><VAR>foo</VAR><TT>^</TT><VAR>bar</VAR><TT>^</TT>' is
synonymous with `<TT>!!:s</TT><TT>^</TT><VAR>foo</VAR><TT>^</TT><VAR>bar</VAR><TT>^</TT>', hence other
modifiers (see <A HREF="zsh_13.html#SEC45">13.1.4 Modifiers</A>) may follow the final `<TT>^</TT>'.
</P>
<P>

If the shell encounters the character sequence `<TT>!&quot;</TT>'
in the input, the history mechanism is temporarily disabled until
the current list (see
<A HREF="zsh_5.html#SEC18">5. Shell Grammar</A>) is fully parsed.  The `<TT>!&quot;</TT>' is removed from the input, and any
subsequent `<TT>!</TT>' characters have no special significance.
</P>
<P>

<A NAME="IDX142"></A>
A less convenient but more comprehensible form of command history support
is provided by the <TT>fc</TT> builtin.
<A NAME="Event Designators"></A>
</P>
<P>

<HR SIZE="6">
<A NAME="SEC43"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC42"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC44"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC40"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC41"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_14.html#SEC63"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_24.html#SEC195">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 13.1.2 Event Designators </H3>
<!--docid::SEC43::-->
<A NAME="IDX143"></A>
<A NAME="IDX144"></A>
An event designator is a reference to a command-line entry in the history
list.  In the list below, remember that the initial <TT>`!'</TT> in each item
may be changed to another character by setting the <TT>histchars</TT>
parameter.
<P>

</P>
<DL COMPACT>
<DT><TT>!</TT>
<DD>Start a history expansion, except when followed by a blank, newline,
`<TT>=</TT>' or `<TT>(</TT>'.  If followed immediately by a word designator
(<A HREF="zsh_13.html#SEC44">13.1.3 Word Designators</A>), this forms a history reference
with no event designator (<A HREF="zsh_13.html#SEC42">13.1.1 Overview</A>).
<P>

</P>
<DT><TT>!!</TT>
<DD>Refer to the previous command.
By itself, this expansion
repeats the previous command.
<P>

</P>
<DT><TT>!</TT><VAR>n</VAR>
<DD>Refer to command-line <VAR>n</VAR>.
<P>

</P>
<DT><TT>!-</TT><VAR>n</VAR>
<DD>Refer to the current command-line minus <VAR>n</VAR>.
<P>

</P>
<DT><TT>!</TT><VAR>str</VAR>
<DD>Refer to the most recent command starting with <VAR>str</VAR>.
<P>

</P>
<DT><TT>!?</TT><VAR>str</VAR>[<TT>?</TT>]
<DD>Refer to the most recent command containing <VAR>str</VAR>.  The trailing
`<TT>?</TT>' is necessary if this reference is to be followed by a modifier or
followed by any text that is not to be considered part of <VAR>str</VAR>.
<P>

</P>
<DT><TT>!#</TT>
<DD>Refer to the current command line typed in so far.  The line is
treated as if it were complete up to and including the word before the
one with the `<TT>!#</TT>' reference.
<P>

</P>
<DT><TT>!{</TT>...<TT>}</TT>
<DD>Insulate a history reference from adjacent characters (if necessary).
<P>

</DL>
<A NAME="Word Designators"></A>
<P>

<HR SIZE="6">
<A NAME="SEC44"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC43"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC45"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC40"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC41"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_14.html#SEC63"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_24.html#SEC195">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 13.1.3 Word Designators </H3>
<!--docid::SEC44::-->
<A NAME="IDX145"></A>
<A NAME="IDX146"></A>
A word designator indicates which word or words of a given command line are
to be included in a history reference.  A `<TT>:</TT>' usually
separates the event specification from the word designator.
It may be omitted only if the word designator begins with a
`<TT>^</TT>', `<TT>$</TT>', `<TT>*</TT>', `<TT>-</TT>' or `<TT>%</TT>'.
Word designators include:
<P>

</P>
<DL COMPACT>
<DT><TT>0</TT>
<DD>The first input word (command).
<DT><VAR>n</VAR>
<DD>The <VAR>n</VAR>th argument.
<DT><TT>^</TT>
<DD>The first argument.  That is, <TT>1</TT>.
<DT><TT>$</TT>
<DD>The last argument.
<DT><TT>%</TT>
<DD>The word matched by (the most recent) <TT>?</TT><VAR>str</VAR> search.
<DT><VAR>x</VAR><TT>-</TT><VAR>y</VAR>
<DD>A range of words; <VAR>x</VAR> defaults to <TT>0</TT>.
<DT><TT>*</TT>
<DD>All the arguments, or a null value if there are none.
<DT><VAR>x</VAR><TT>*</TT>
<DD>Abbreviates `<VAR>x</VAR><TT>-$</TT>'.
<DT><VAR>x</VAR><TT>-</TT>
<DD>Like `<VAR>x</VAR><TT>*</TT>' but omitting word <TT>$</TT>.
</DL>
<P>

Note that a `<TT>%</TT>' word designator works only when used in one of
`<TT>!%</TT>', `<TT>!:%</TT>' or `<TT>!?</TT><VAR>str</VAR><TT>?:%</TT>', and only when used after a
<TT>!?</TT> expansion (possibly in an earlier command).  Anything else results
in an error, although the error may not be the most obvious one.
<A NAME="Modifiers"></A>
</P>
<P>

<HR SIZE="6">
<A NAME="SEC45"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC44"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC46"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC40"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC41"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_14.html#SEC63"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_24.html#SEC195">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 13.1.4 Modifiers </H3>
<!--docid::SEC45::-->
<A NAME="IDX147"></A>
<A NAME="IDX148"></A>
<A NAME="IDX149"></A>
<A NAME="IDX150"></A>
<A NAME="IDX151"></A>
After the optional word designator, you can add
a sequence of one or more of the following modifiers,
each preceded by a `<TT>:</TT>'.  These modifiers also work on the result
of <EM>filename generation</EM> and <EM>parameter expansion</EM>, except where
noted.
<P>

</P>
<DL COMPACT>
<DT><TT>h</TT>
<DD>Remove a trailing pathname component, leaving the head.  This works
like `<TT>dirname</TT>'.
<P>

</P>
<DT><TT>r</TT>
<DD>Remove a filename extension of the form `<TT>.</TT><VAR>xxx</VAR>', leaving
the root name.
<P>

</P>
<DT><TT>e</TT>
<DD>Remove all but the extension.
<P>

</P>
<DT><TT>t</TT>
<DD>Remove all leading pathname components, leaving the tail.  This works
like `<TT>basename</TT>'.
<P>

</P>
<DT><TT>p</TT>
<DD>Print the new command but do not execute it.  Only works with history
expansion.
<P>

</P>
<DT><TT>q</TT>
<DD>Quote the substituted words, escaping further substitutions.  Works
with history expansion and parameter expansion, though for parameters
it is only useful if the resulting text is to be re-evaluated such as
by <TT>eval</TT>.
<P>

</P>
<DT><TT>Q</TT>
<DD>Remove one level of quotes from the substituted words.
<P>

</P>
<DT><TT>x</TT>
<DD>Like <TT>q</TT>, but break into words at whitespace.  Does not work with
parameter expansion.
<P>

</P>
<DT><TT>l</TT>
<DD>Convert the words to all lowercase.
<P>

</P>
<DT><TT>u</TT>
<DD>Convert the words to all uppercase.
<P>

</P>
<DT><TT>s/</TT><VAR>l</VAR><TT>/</TT><VAR>r</VAR>[<TT>/</TT>]
<DD>Substitute <VAR>r</VAR> for <VAR>l</VAR> as described below.
Unless preceded immediately by a <TT>g</TT>, with no colon between,
the substitution is done only for the
first string that matches <VAR>l</VAR>.  For arrays and for filename
generation, this applies to each word of the expanded text.
<P>

</P>
<DT><TT>&amp;</TT>
<DD>Repeat the previous <TT>s</TT> substitution.  Like <TT>s</TT>, may be preceded
immediately by a <TT>g</TT>.  In parameter expansion the <TT>&amp;</TT> must appear
inside braces, and in filename generation it must be quoted with a
backslash.
<P>

</DL>
<P>

The <TT>s/l/r/</TT> substitution works as follows.  The left-hand side of
substitutions are not regular expressions, but character strings.  Any
character can be used as the delimiter in place of `<TT>/</TT>'.  A
backslash quotes the delimiter character.  The character `<TT>&amp;</TT>', in
the right-hand-side <VAR>r</VAR>, is replaced by the text from the
left-hand-side <VAR>l</VAR>.  The `<TT>&amp;</TT>' can be quoted with a backslash.  A
null <VAR>l</VAR> uses the previous string either from the previous <VAR>l</VAR>
or from the contextual scan string <VAR>s</VAR> from `<TT>!?</TT><VAR>s</VAR>'.  You can
omit the rightmost delimiter if a newline immediately follows <VAR>r</VAR>;
the rightmost `<TT>?</TT>' in a context scan can similarly be omitted.
Note the same record of the last <VAR>l</VAR> and <VAR>r</VAR> is maintained
across all forms of expansion.
</P>
<P>

The following <TT>f</TT>, <TT>F</TT>, <TT>w</TT> and <TT>W</TT> modifiers work only with
parameter expansion and filename generation.  They are listed here to
provide a single point of reference for all modifiers.
</P>
<P>

</P>
<DL COMPACT>
<DT><TT>f</TT>
<DD>Repeats the immediately (without a colon) following modifier until the
resulting word doesn't change any more.
<P>

</P>
<DT><TT>F:</TT><VAR>expr</VAR><TT>:</TT>
<DD>Like <TT>f</TT>, but repeats only <VAR>n</VAR> times if the expression
<VAR>expr</VAR> evaluates to <VAR>n</VAR>.  Any character can be used instead of
the `<TT>:</TT>'; if `<TT>(</TT>', `<TT>[</TT>', or `<TT>{</TT>'
is used as the opening delimiter,
the closing delimiter should be '<TT>)</TT>', `<TT>]</TT>', or `<TT>}</TT>',
respectively.
<P>

</P>
<DT><TT>w</TT>
<DD>Makes the immediately following modifier work on each word in the
string.
<P>

</P>
<DT><TT>W:</TT><VAR>sep</VAR><TT>:</TT>
<DD>Like <TT>w</TT> but words are considered to be the parts of the string
that are separated by <VAR>sep</VAR>. Any character can be used instead of
the `<TT>:</TT>'; opening parentheses are handled specially, see above.
<P>

</DL>
<A NAME="Process Substitution"></A>
<P>

<HR SIZE="6">
<A NAME="SEC46"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC45"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC47"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC40"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC40"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_14.html#SEC63"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_24.html#SEC195">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 13.2 Process Substitution </H2>
<!--docid::SEC46::-->
<A NAME="IDX152"></A>
<A NAME="IDX153"></A>
Each command argument of the form
`<TT>&lt;(</TT><VAR>list</VAR><TT>)</TT>',
`<TT>&gt;(</TT><VAR>list</VAR><TT>)</TT>' or
`<TT>=(</TT><VAR>list</VAR><TT>)</TT>'
is subject to process substitution.
In the case of the <TT>&lt;</TT> or <TT>&gt;</TT> forms, the shell runs process
<VAR>list</VAR> asynchronously.  If the system supports the <TT>/dev/fd</TT>
mechanism, the command argument is the name of the device file
corresponding to a file descriptor; otherwise, if the system supports named
pipes (FIFOs), the command argument will be a named pipe.  If the form with
<TT>&gt;</TT> is selected then writing on this special file will provide input for
<VAR>list</VAR>.  If <TT>&lt;</TT> is used, then the file passed as an argument will
be connected to the output of the <VAR>list</VAR> process.  For example,
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre><TT>paste &lt;(cut -f1</TT> <VAR>file1</VAR><TT>) &lt;(cut -f3</TT> <VAR>file2</VAR><TT>) |
tee &gt;(</TT><VAR>process1</VAR><TT>) &gt;(</TT><VAR>process2</VAR><TT>) &gt;/dev/null</TT>
</pre></td></tr></table><P>

cuts fields 1 and 3 from the files <VAR>file1</VAR> and <VAR>file2</VAR> respectively,
pastes the results together, and sends it to the processes
<VAR>process1</VAR> and <VAR>process2</VAR>.
</P>
<P>

Both the <TT>/dev/fd</TT> and the named pipe implementation have drawbacks.  In
the former case, some programmes may automatically close the file
descriptor in question before examining the file on the command line,
particularly if this is necessary for security reasons such as when the
programme is running setuid.  In the second case, if the
programme does not actually open the file, the subshell attempting to read
from or write to the pipe will (in a typical implementation, different
operating systems may have different behaviour) block for ever and have to
be killed explicitly.  In both cases, the shell actually supplies the
information using a pipe, so that programmes that expect to lseek
(see man page lseek(2)) on the file will not work.
</P>
<P>

Also note that the previous example can be more compactly and
efficiently written (provided the <TT>MULTIOS</TT> option is set) as:
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre><TT>paste &lt;(cut -f1</TT> <VAR>file1</VAR><TT>) &lt;(cut -f3</TT> <VAR>file2</VAR><TT>)</TT> <TT>&gt; &gt;(</TT><VAR>process1</VAR><TT>) &gt; &gt;(</TT><VAR>process2</VAR><TT>)</TT>
</pre></td></tr></table><P>

The shell uses pipes instead of FIFOs to implement the latter
two process substitutions in the above example.
</P>
<P>

If <TT>=</TT> is used,
then the file passed as an argument will be the name
of a temporary file containing the output of the <VAR>list</VAR>
process.  This may be used instead of the <TT>&lt;</TT>
form for a program that expects to lseek (see man page lseek(2))
on the input file.
<A NAME="Parameter Expansion"></A>
</P>
<P>

<HR SIZE="6">
<A NAME="SEC47"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC46"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC48"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC40"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC40"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_14.html#SEC63"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_24.html#SEC195">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 13.3 Parameter Expansion </H2>
<!--docid::SEC47::-->
<A NAME="IDX154"></A>
<A NAME="IDX155"></A>
The character `<TT>$</TT>' is used to introduce parameter expansions.
See
<A HREF="zsh_14.html#SEC63">14. Parameters</A>
for a description of parameters, including arrays, associative arrays,
and subscript notation to access individual array elements.
<P>

In the expansions discussed below that require a pattern, the form of
the pattern is the same as that used for filename generation;
see <A HREF="zsh_13.html#SEC55">13.8 Filename Generation</A>.  Note that these patterns, along with
the replacement text of any substitutions, are themselves subject to
parameter expansion, command substitution, and arithmetic expansion.
In addition to the following operations, the colon modifiers described in
<A HREF="zsh_13.html#SEC45">13.1.4 Modifiers</A> in <A HREF="zsh_13.html#SEC41">13.1 History Expansion</A> can be
applied:  for example, <TT>${i:s/foo/bar/}</TT> performs string
substitution on the expansion of parameter <TT>$i</TT>.
</P>
<P>

</P>
<DL COMPACT>
<DT><TT>${</TT><VAR>name</VAR><TT>}</TT>
<DD>The value, if any, of the parameter <VAR>name</VAR> is substituted.
The braces are required if the expansion is to be followed by
a letter, digit, or underscore that is not to be interpreted
as part of <VAR>name</VAR>.  In addition, more complicated forms of substitution
usually require the braces to be present; exceptions, which only apply if
the option <TT>KSH_ARRAYS</TT> is not set, are a single subscript or any colon
modifiers appearing after the name, or any of the characters `<TT>^</TT>',
`<TT>=</TT>', `<TT>~</TT>', `<TT>#</TT>' or `<TT>+</TT>' appearing before the name, all of
which work with or without braces.
<P>

If <VAR>name</VAR> is an array parameter, and the <TT>KSH_ARRAYS</TT> option is not
set, then the value of each
element of <VAR>name</VAR> is substituted, one element per word.  Otherwise, the
expansion results in one word only; with <TT>KSH_ARRAYS</TT>, this is the first
element of an array.  No field splitting is done on the result unless the
<TT>SH_WORD_SPLIT</TT> option is set.
</P>
<P>

</P>
<DT><TT>${+</TT><VAR>name</VAR><TT>}</TT>
<DD>If <VAR>name</VAR> is the name of a set parameter `<TT>1</TT>' is substituted,
otherwise `<TT>0</TT>' is substituted.
<P>

</P>
<DT><TT>${</TT><VAR>name</VAR><TT>:-</TT><VAR>word</VAR><TT>}</TT>
<DD>If <VAR>name</VAR> is set and is non-null then substitute its
value; otherwise substitute <VAR>word</VAR>. If <VAR>name</VAR> is
missing, substitute <VAR>word</VAR>.
<P>

</P>
<DT><TT>${</TT><VAR>name</VAR><TT>:=</TT><VAR>word</VAR><TT>}</TT>
<DD><DT><TT>${</TT><VAR>name</VAR><TT>::=</TT><VAR>word</VAR><TT>}</TT>
<DD>In the first form, if <VAR>name</VAR> is unset or is null then
set it to <VAR>word</VAR>; in the second form, unconditionally
set <VAR>name</VAR> to <VAR>word</VAR>.  In both forms, the value of
the parameter is then substituted.
<P>

</P>
<DT><TT>${</TT><VAR>name</VAR><TT>:?</TT><VAR>word</VAR><TT>}</TT>
<DD>If <VAR>name</VAR> is set and is non-null then substitute
its value; otherwise, print <VAR>word</VAR> and exit from the shell.
Interactive shells instead return to the prompt.
If <VAR>word</VAR> is omitted, then a standard message is printed.
<P>

</P>
<DT><TT>${</TT><VAR>name</VAR><TT>:+</TT><VAR>word</VAR><TT>}</TT>
<DD>If <VAR>name</VAR> is set and is non-null then substitute
<VAR>word</VAR>; otherwise substitute nothing.
<P>

</DL>
<P>

If the colon is omitted from one of the above expressions
containing a colon, then the shell only checks whether
<VAR>name</VAR> is set, not whether its value is null.
</P>
<P>

In the following expressions, when <VAR>name</VAR> is an array and
the substitution is not quoted, or if the `<TT>(@)</TT>' flag or the
<VAR>name</VAR><TT>[@]</TT> syntax is used, matching and replacement is
performed on each array element separately.
</P>
<P>

</P>
<DL COMPACT>
<DT><TT>${</TT><VAR>name</VAR><TT>#</TT><VAR>pattern</VAR><TT>}</TT>
<DD><DT><TT>${</TT><VAR>name</VAR><TT>##</TT><VAR>pattern</VAR><TT>}</TT>
<DD>If the <VAR>pattern</VAR> matches the beginning of the value of
<VAR>name</VAR>, then substitute the value of <VAR>name</VAR> with
the matched portion deleted; otherwise, just
substitute the value of <VAR>name</VAR>.  In the first
form, the smallest matching pattern is preferred;
in the second form, the largest matching pattern is
preferred.
<P>

</P>
<DT><TT>${</TT><VAR>name</VAR><TT>%</TT><VAR>pattern</VAR><TT>}</TT>
<DD><DT><TT>${</TT><VAR>name</VAR><TT>%%</TT><VAR>pattern</VAR><TT>}</TT>
<DD>If the <VAR>pattern</VAR> matches the end of the value of
<VAR>name</VAR>, then substitute the value of <VAR>name</VAR> with
the matched portion deleted; otherwise, just
substitute the value of <VAR>name</VAR>.  In the first
form, the smallest matching pattern is preferred;
in the second form, the largest matching pattern is
preferred.
<P>

</P>
<DT><TT>${</TT><VAR>name</VAR><TT>:#</TT><VAR>pattern</VAR><TT>}</TT>
<DD>If the <VAR>pattern</VAR> matches the value of <VAR>name</VAR>, then substitute
the empty string; otherwise, just substitute the value of <VAR>name</VAR>.
If <VAR>name</VAR> is an array
the matching array elements are removed (use the `<TT>(M)</TT>' flag to
remove the non-matched elements).
<P>

</P>
<DT><TT>${</TT><VAR>name</VAR><TT>/</TT><VAR>pattern</VAR><TT>/</TT><VAR>repl</VAR><TT>}</TT>
<DD><DT><TT>${</TT><VAR>name</VAR><TT>//</TT><VAR>pattern</VAR><TT>/</TT><VAR>repl</VAR><TT>}</TT>
<DD>Replace the longest possible match of <VAR>pattern</VAR> in the expansion of
parameter <VAR>name</VAR> by string <VAR>repl</VAR>.  The first form
replaces just the first occurrence, the second form all occurrences.
Both <VAR>pattern</VAR> and <VAR>repl</VAR> are subject to double-quoted substitution,
so that expressions like <TT>${name/$opat/$npat}</TT> will work, but note the
usual rule that pattern characters in <TT>$opat</TT> are not treated specially
unless either the option <TT>GLOB_SUBST</TT> is set, or <TT>$opat</TT> is instead
substituted as <TT>${~opat}</TT>.
<P>

The <VAR>pattern</VAR> may begin with a `<TT>#</TT>', in which case the
<VAR>pattern</VAR> must match at the start of the string, or `<TT>%</TT>', in
which case it must match at the end of the string.  The <VAR>repl</VAR> may
be an empty string, in which case the final `<TT>/</TT>' may also be omitted.
To quote the final `<TT>/</TT>' in other cases it should be preceded by two
backslashes (i.e., a quoted backslash); this is not necessary if the
`<TT>/</TT>' occurs inside a substituted parameter.  Note also that the `<TT>#</TT>'
and `<TT>%</TT>' are not active if they occur inside a substituted parameter,
even at the start.
</P>
<P>

The first `<TT>/</TT>' may be preceded by a `<TT>:</TT>', in which case the match
will only succeed if it matches the entire word.  Note also the
effect of the <TT>I</TT> and <TT>S</TT> parameter expansion flags below; however,
the flags <TT>M</TT>, <TT>R</TT>, <TT>B</TT>, <TT>E</TT> and <TT>N</TT> are not useful.
</P>
<P>

For example,
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>foo=&quot;twinkle twinkle little star&quot; sub=&quot;t*e&quot; rep=&quot;spy&quot;
print ${foo//${~sub}/$rep}
print ${(S)foo//${~sub}/$rep}
</pre></td></tr></table><P>

Here, the `<TT>~</TT>' ensures that the text of <TT>$sub</TT> is treated as a
pattern rather than a plain string.  In the first case, the longest
match for <TT>t*e</TT> is substituted and the result is `<TT>spy star</TT>',
while in the second case, the shortest matches are taken and the
result is `<TT>spy spy lispy star</TT>'.
</P>
<P>

</P>
<DT><TT>${#</TT><VAR>spec</VAR><TT>}</TT>
<DD>If <VAR>spec</VAR> is one of the above substitutions, substitute
the length in characters of the result instead of
the result itself.  If <VAR>spec</VAR> is an array expression,
substitute the number of elements of the result.
Note that `<TT>^</TT>', `<TT>=</TT>', and `<TT>~</TT>', below, must appear
to the left of `<TT>#</TT>' when these forms are combined.
<P>

</P>
<DT><TT>${^</TT><VAR>spec</VAR><TT>}</TT>
<DD><A NAME="IDX156"></A>
<A NAME="IDX157"></A>
<A NAME="IDX158"></A>
Turn on the <TT>RC_EXPAND_PARAM</TT> option for the
evaluation of <VAR>spec</VAR>; if the `<TT>^</TT>' is doubled, turn it off.
When this option is set, array expansions of the form
<VAR>foo</VAR><TT>${</TT><VAR>xx</VAR><TT>}</TT><VAR>bar</VAR>,
where the parameter <VAR>xx</VAR>
is set to <TT>(</TT><VAR>a b c</VAR><TT>)</TT>, are substituted with
`<VAR>fooabar foobbar foocbar</VAR>' instead of the default
`<VAR>fooa b cbar</VAR>'.
<P>

Internally, each such expansion is converted into the
equivalent list for brace expansion.  E.g., <TT>${^var}</TT> becomes
<TT>{$var[1],$var[2],</TT>...<TT>}</TT>, and is processed as described in
<A HREF="zsh_13.html#SEC53">13.6 Brace Expansion</A> below.
If word splitting is also in effect the
<TT>$var[</TT><VAR>N</VAR><TT>]</TT> may themselves be split into different list
elements.
</P>
<P>

</P>
<DT><TT>${=</TT><VAR>spec</VAR><TT>}</TT>
<DD><A NAME="IDX159"></A>
<A NAME="IDX160"></A>
<A NAME="IDX161"></A>
Perform word splitting using the rules for <TT>SH_WORD_SPLIT</TT> during the
evaluation of <VAR>spec</VAR>, but regardless of whether the parameter appears in
double quotes; if the `<TT>=</TT>' is doubled, turn it off.
<A NAME="IDX162"></A>
This forces parameter expansions to be split into
separate words before substitution, using <TT>IFS</TT> as a delimiter.
This is done by default in most other shells.
<P>

Note that splitting is applied to <VAR>word</VAR> in the assignment forms
of <VAR>spec</VAR> <EM>before</EM> the assignment to <VAR>name</VAR> is performed.
This affects the result of array assignments with the <TT>A</TT> flag.
</P>
<P>

</P>
<DT><TT>${~</TT><VAR>spec</VAR><TT>}</TT>
<DD><A NAME="IDX163"></A>
Turn on the <TT>GLOB_SUBST</TT> option for the evaluation of
<VAR>spec</VAR>; if the `<TT>~</TT>' is doubled, turn it off.  When this option is
set, the string resulting from the expansion will be interpreted as a
pattern anywhere that is possible, such as in filename expansion and
filename generation and pattern-matching contexts like the right
hand side of the `<TT>=</TT>' and `<TT>!=</TT>' operators in conditions.
<P>

</DL>
<P>

If a <TT>${</TT>...<TT>}</TT> type parameter expression or a
<TT>$(</TT>...<TT>)</TT> type command substitution is used in place of
<VAR>name</VAR> above, it is expanded first and the result is used as if
it were the value of <VAR>name</VAR>.  Thus it is
possible to perform nested operations:  <TT>${${foo#head}%tail}</TT>
substitutes the value of <TT>$foo</TT> with both `<TT>head</TT>' and `<TT>tail</TT>'
deleted.  The form with <TT>$(</TT>...<TT>)</TT> is often useful in
combination with the flags described next; see the examples below.
Each <VAR>name</VAR> or nested <TT>${</TT>...<TT>}</TT> in a parameter expansion may
also be followed by a subscript expression as described in
<A HREF="zsh_14.html#SEC65">14.2 Array Parameters</A>.
</P>
<P>

Note that double quotes may appear around nested expressions, in which
case only the part inside is treated as quoted; for example,
<TT>${(f)&quot;$(foo)&quot;}</TT> quotes the result of <TT>$(foo)</TT>, but the flag `<TT>(f)</TT>'
(see below) is applied using the rules for unquoted expansions.  Note
further that quotes are themselves nested in this context; for example, in
<TT>&quot;${(@f)&quot;$(foo)&quot;}&quot;</TT>, there are two sets of quotes, one surrounding the
whole expression, the other (redundant) surrounding the <TT>$(foo)</TT> as
before.
</P>
<P>

</P>
<P>

<HR SIZE="6">
<A NAME="SEC48"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC47"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC49"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC40"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC40"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_14.html#SEC63"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_24.html#SEC195">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 13.3.1 Parameter Expansion Flags </H3>
<!--docid::SEC48::-->
<A NAME="IDX164"></A>
<A NAME="IDX165"></A>
<A NAME="IDX166"></A>
If the opening brace is directly followed by an opening parenthesis,
the string up to the matching closing parenthesis will be taken as a
list of flags.  In cases where repeating a flag is meaningful, the
repetitions need not be consecutive; for example, `(<TT>q%q%q</TT>)'
means the same thing as the more readable `(<TT>%%qqq</TT>)'.  The
following flags are supported:
<P>

</P>
<DL COMPACT>
<DT><TT>%</TT>
<DD>Expand all <TT>%</TT> escapes in the resulting words in the same way as in in
prompts (see <A HREF="zsh_12.html#SEC39">12. Prompt Expansion</A>). If this flag is given twice,
full prompt expansion is done on the resulting words, depending on the
setting of the <TT>PROMPT_PERCENT</TT>, <TT>PROMPT_SUBST</TT> and <TT>PROMPT_BANG</TT>
options.
<P>

</P>
<DT><TT>@</TT>
<DD>In double quotes, array elements are put into separate words.
E.g., `<TT>&quot;${(@)foo}&quot;</TT>' is equivalent to `<TT>&quot;${foo[@]}&quot;</TT>' and
`<TT>&quot;${(@)foo[1,2]}&quot;</TT>' is the same as `<TT>&quot;$foo[1]&quot; &quot;$foo[2]&quot;</TT>'.
This is distinct from <EM>field splitting</EM> by the the <TT>f</TT>, <TT>s</TT>
or <TT>z</TT> flags, which still applies within each array element.
<P>

</P>
<DT><TT>A</TT>
<DD>Create an array parameter with `<TT>${</TT>...<TT>=</TT>...<TT>}</TT>',
`<TT>${</TT>...<TT>:=</TT>...<TT>}</TT>' or `<TT>${</TT>...<TT>::=</TT>...<TT>}</TT>'.
If this flag is repeated (as in `<TT>AA</TT>'), create an associative
array parameter.  Assignment is made before sorting or padding.
The <VAR>name</VAR> part may be a subscripted range for ordinary
arrays; the <VAR>word</VAR> part <EM>must</EM> be converted to an array, for
example by using `<TT>${(AA)=</TT><VAR>name</VAR><TT>=</TT>...<TT>}</TT>' to activate
field splitting, when creating an associative array.
<P>

</P>
<DT><TT>c</TT>
<DD>With <TT>${#</TT><VAR>name</VAR><TT>}</TT>, count the total number of characters in an array,
as if the elements were concatenated with spaces between them.
<P>

</P>
<DT><TT>C</TT>
<DD>Capitalize the resulting words.  `Words' in this case refers to sequences
of alphanumeric characters separated by non-alphanumerics, <EM>not</EM> to words
that result from field splitting.
<P>

</P>
<DT><TT>e</TT>
<DD>Perform <EM>parameter expansion</EM>, <EM>command substitution</EM> and
<EM>arithmetic expansion</EM> on the result. Such expansions can be
nested but too deep recursion may have unpredictable effects.
<P>

</P>
<DT><TT>f</TT>
<DD>Split the result of the expansion to lines. This is a shorthand
for `<TT>ps:\n:</TT>'.
<P>

</P>
<DT><TT>F</TT>
<DD>Join the words of arrays together using newline as a separator.
This is a shorthand for `<TT>pj:\n:</TT>'.
<P>

</P>
<DT><TT>i</TT>
<DD>With <TT>o</TT> or <TT>O</TT>, sort case-independently.
<P>

</P>
<DT><TT>k</TT>
<DD>If <VAR>name</VAR> refers to an associative array, substitute the <EM>keys</EM>
(element names) rather than the values of the elements.  Used with
subscripts (including ordinary arrays), force indices or keys to be
substituted even if the subscript form refers to values.  However,
this flag may not be combined with subscript ranges.
<P>

</P>
<DT><TT>L</TT>
<DD>Convert all letters in the result to lower case.
<P>

</P>
<DT><TT>o</TT>
<DD>Sort the resulting words in ascending order.
<P>

</P>
<DT><TT>O</TT>
<DD>Sort the resulting words in descending order.
<P>

</P>
<DT><TT>P</TT>
<DD>This forces the value of the parameter <VAR>name</VAR> to be interpreted as a
further parameter name, whose value will be used where appropriate. If
used with a nested parameter or command substitution, the result of that
will be taken as a parameter name in the same way.  For example, if you
have `<TT>foo=bar</TT>' and `<TT>bar=baz</TT>', the strings <TT>${(P)foo}</TT>,
<TT>${(P)${foo}}</TT>, and <TT>${(P)$(echo bar)}</TT> will be expanded to `<TT>baz</TT>'.
<P>

</P>
<DT><TT>q</TT>
<DD>Quote the resulting words with backslashes. If this flag is given
twice, the resulting words are quoted in single quotes and if it is
given three times, the words are quoted in double quotes. If it is
given four times, the words are quoted in single quotes preceded by a <TT>$</TT>.
<P>

</P>
<DT><TT>Q</TT>
<DD>Remove one level of quotes from the resulting words.
<P>

</P>
<DT><TT>t</TT>
<DD>Use a string describing the type of the parameter where the value
of the parameter would usually appear. This string consists of keywords
separated by hyphens (`<TT>-</TT>'). The first keyword in the string describes
the main type, it can be one of `<TT>scalar</TT>', `<TT>array</TT>', `<TT>integer</TT>',
`<TT>float</TT>' or `<TT>association</TT>'. The other keywords describe the type in
more detail:
<P>

</P>
<DL COMPACT>
<DT><TT>local</TT>
<DD>for local parameters
<P>

</P>
<DT><TT>left</TT>
<DD>for left justified parameters
<P>

</P>
<DT><TT>right_blanks</TT>
<DD>for right justified parameters with leading blanks
<P>

</P>
<DT><TT>right_zeros</TT>
<DD>for right justified parameters with leading zeros
<P>

</P>
<DT><TT>lower</TT>
<DD>for parameters whose value is converted to all lower case when it is
expanded
<P>

</P>
<DT><TT>upper</TT>
<DD>for parameters whose value is converted to all upper case when it is
expanded
<P>

</P>
<DT><TT>readonly</TT>
<DD>for readonly parameters
<P>

</P>
<DT><TT>tag</TT>
<DD>for tagged parameters
<P>

</P>
<DT><TT>export</TT>
<DD>for exported parameters
<P>

</P>
<DT><TT>unique</TT>
<DD>for arrays which keep only the first occurrence of duplicated values
<P>

</P>
<DT><TT>hide</TT>
<DD>for parameters with the `hide' flag
<P>

</P>
<DT><TT>special</TT>
<DD>for special parameters defined by the shell
<P>

</DL>
<P>

</P>
<DT><TT>U</TT>
<DD>Convert all letters in the result to upper case.
<P>

</P>
<DT><TT>v</TT>
<DD>Used with <TT>k</TT>, substitute (as two consecutive words) both the key
and the value of each associative array element.  Used with subscripts,
force values to be substituted even if the subscript form refers to
indices or keys.
<P>

</P>
<DT><TT>V</TT>
<DD>Make any special characters in the resulting words visible.
<P>

</P>
<DT><TT>w</TT>
<DD>With <TT>${#</TT><VAR>name</VAR><TT>}</TT>, count words in arrays or strings; the <TT>s</TT>
flag may be used to set a word delimiter.
<P>

</P>
<DT><TT>W</TT>
<DD>Similar to <TT>w</TT> with the difference that empty words between
repeated delimiters are also counted.
<P>

</P>
<DT><TT>X</TT>
<DD>With this flag parsing errors occurring with the <TT>Q</TT> and <TT>e</TT> flags or the
pattern matching forms such as `<TT>${</TT><VAR>name</VAR><TT>#</TT><VAR>pattern</VAR><TT>}</TT>' 
are reported. Without the flag they are silently ignored.
<P>

</P>
<DT><TT>z</TT>
<DD>Split the result of the expansion into words using shell parsing to
find the words, i.e. taking into account any quoting in the value.
<P>

Note that this is done very late, as for the `<TT>(s)</TT>' flag. So to
access single words in the result, one has to use nested expansions as 
in `<TT>${${(z)foo}[2]}</TT>'. Likewise, to remove the quotes in the
resulting words one would do: `<TT>${(Q)${(z)foo}}</TT>'.
</P>
<P>

</DL>
<P>

The following flags (except <TT>p</TT>) are followed by one or more arguments
as shown.  Any character, or the matching pairs `<TT>(</TT>...<TT>)</TT>',
`<TT>{</TT>...<TT>}</TT>', `<TT>[</TT>...<TT>]</TT>', or `<TT>&lt;</TT>...<TT>&gt;</TT>', may be used in place
of a colon as delimiters, but note that when a flag takes more than one
argument, a matched pair of delimiters must surround each argument.
</P>
<P>

</P>
<DL COMPACT>
<DT><TT>p</TT>
<DD>Recognize the same escape sequences as the <TT>print</TT> builtin
in string arguments to any of the flags described below.
<P>

</P>
<DT><TT>j:</TT><VAR>string</VAR><TT>:</TT>
<DD>Join the words of arrays together using <VAR>string</VAR> as a separator.
<A NAME="IDX167"></A>
Note that this occurs before field splitting by the <TT>SH_WORD_SPLIT</TT>
option.
<P>

</P>
<DT><TT>l:</TT><VAR>expr</VAR><TT>::</TT><VAR>string1</VAR><TT>::</TT><VAR>string2</VAR><TT>:</TT>
<DD>Pad the resulting words on the left.  Each word will be truncated if
required and placed in a field <VAR>expr</VAR> characters wide.  The space
to the left will be filled with <VAR>string1</VAR> (concatenated as often
as needed) or spaces if <VAR>string1</VAR> is not given.  If both
<VAR>string1</VAR> and <VAR>string2</VAR> are given, this string is inserted
once directly to the left of each word, before padding.
<P>

</P>
<DT><TT>r:</TT><VAR>expr</VAR><TT>::</TT><VAR>string1</VAR><TT>::</TT><VAR>string2</VAR><TT>:</TT>
<DD>As <TT>l</TT>, but pad the words on the right and insert <VAR>string2</VAR>
on the right.
<P>

</P>
<DT><TT>s:</TT><VAR>string</VAR><TT>:</TT>
<DD>Force field splitting (see the option <TT>SH_WORD_SPLIT</TT>) at the
separator <VAR>string</VAR>.  Note that a <VAR>string</VAR> of two or more
characters means all must all match in sequence; this differs from
the treatment of two or more characters in the <TT>IFS</TT> parameter.
<P>

</DL>
<P>

The following flags are meaningful with the <TT>${</TT>...<TT>#</TT>...<TT>}</TT> or
<TT>${</TT>...<TT>%</TT>...<TT>}</TT> forms.  The <TT>S</TT> and <TT>I</TT> flags may also be
used with the <TT>${</TT>...<TT>/</TT>...<TT>}</TT> forms.
</P>
<P>

</P>
<DL COMPACT>
<DT><TT>S</TT>
<DD>Search substrings as well as beginnings or ends; with <TT>#</TT> start
from the beginning and with <TT>%</TT> start from the end of the string.
With substitution via <TT>${</TT>...<TT>/</TT>...<TT>}</TT> or
<TT>${</TT>...<TT>//</TT>...<TT>}</TT>, specifies non-greedy matching, i.e. that the
shortest instead of the longest match should be replaced.
<P>

</P>
<DT><TT>I:</TT><VAR>expr</VAR><TT>:</TT>
<DD>Search the <VAR>expr</VAR>th match (where <VAR>expr</VAR> evaluates to a number).
This only applies when searching for substrings, either with the <TT>S</TT>
flag, or with <TT>${</TT>...<TT>/</TT>...<TT>}</TT> (only the <VAR>expr</VAR>th match is
substituted) or <TT>${</TT>...<TT>//</TT>...<TT>}</TT> (all matches from the
<VAR>expr</VAR>th on are substituted).  The default is to take the first match.
<P>

The <VAR>expr</VAR>th match is counted such that there is either one or zero
matches from each starting position in the string, although for global
substitution matches overlapping previous replacements are ignored.  With
the <TT>${</TT>...<TT>%</TT>...<TT>}</TT> and <TT>${</TT>...<TT>%%</TT>...<TT>}</TT> forms, the starting
position for the match moves backwards from the end as the index increases,
while with the other forms it moves forward from the start.
</P>
<P>

Hence with the string
<TABLE><tr><td>&nbsp;</td><td class=example><pre>which switch is the right switch for Ipswich?
</pre></td></tr></table>substitutions of the form
<TT>${</TT>(<TT>SI:</TT><VAR>N</VAR><TT>:</TT>)<TT>string#w*ch}</TT> as <VAR>N</VAR> increases
from 1 will match and remove `<TT>which</TT>', `<TT>witch</TT>', `<TT>witch</TT>' and
`<TT>wich</TT>'; the form using `<TT>##</TT>' will match and remove `<TT>which switch
is the right switch for Ipswich</TT>', `<TT>witch is the right switch for
Ipswich</TT>', `<TT>witch for Ipswich</TT>' and `<TT>wich</TT>'. The form using `<TT>%</TT>'
will remove the same matches as for `<TT>#</TT>', but in reverse order, and the
form using `<TT>%%</TT>' will remove the same matches as for `<TT>##</TT>' in reverse
order.
<P>

</P>
<DT><TT>B</TT>
<DD>Include the index of the beginning of the match in the result.
<P>

</P>
<DT><TT>E</TT>
<DD>Include the index of the end of the match in the result.
<P>

</P>
<DT><TT>M</TT>
<DD>Include the matched portion in the result.
<P>

</P>
<DT><TT>N</TT>
<DD>Include the length of the match in the result.
<P>

</P>
<DT><TT>R</TT>
<DD>Include the unmatched portion in the result (the <EM>R</EM>est).
<P>

</DL>
<P>

</P>
<P>

<HR SIZE="6">
<A NAME="SEC49"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC48"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC50"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC40"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC40"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_14.html#SEC63"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_24.html#SEC195">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 13.3.2 Rules </H3>
<!--docid::SEC49::-->
<P>

Here is a summary of the rules for substitution; this assumes that braces
are present around the substitution, i.e. <TT>${...}</TT>.  Some particular
examples are given below.  Note that the Zsh Development Group accepts
<EM>no responsibility</EM> for any brain damage which may occur during the
reading of the following rules.
</P>
<P>

</P>
<DL COMPACT>
<DT><TT>1.</TT> <EM>Nested Substitution</EM>
<DD>If multiple nested <TT>${...}</TT> forms are present, substitution is
performed from the inside outwards.  At each level, the substitution takes
account of whether the current value is a scalar or an array, whether the
whole substitution is in double quotes, and what flags are supplied to the
current level of substitution, just as if the nested substitution were the
outermost.  The flags are not propagated up to enclosing
substitutions; the nested substitution will return either a scalar or an
array as determined by the flags, possibly adjusted for quoting.  All the
following steps take place where applicable at all levels of substitution.
Note that, unless the `<TT>(P)</TT>' flag is present, the flags and any subscripts
apply directly to the value of the nested substitution; for example, the
expansion <TT>${${foo}}</TT> behaves exactly the same as <TT>${foo}</TT>.
<P>

</P>
<DT><TT>2.</TT> <EM>Parameter Subscripting</EM>
<DD>If the value is a raw parameter reference with a subscript, such as
<TT>${</TT><VAR>var</VAR><TT>[3]}</TT>, the effect of subscripting is applied directly to
the parameter.  Subscripts are evaluated left to right; subsequent
subscripts apply to the scalar or array value yielded by the previous
subscript.  Thus if <TT>var</TT> is an array, <TT>${var[1][2]}</TT> is the second
character of the first word, but <TT>${var[2,4][2]}</TT> is the entire third
word (the second word of the range of words two through four of the
original array).  Any number of subscripts may appear.
<P>

</P>
<DT><TT>3.</TT> <EM>Parameter Name Replacement</EM>
<DD>The effect of any <TT>(P)</TT> flag, which treats the value so far as a
parameter name and replaces it with the corresponding value, is applied.
<P>

</P>
<DT><TT>4.</TT> <EM>Double-Quoted Joining</EM>
<DD>If the value after this process is an array, and the substitution
appears in double quotes, and no <TT>(@)</TT> flag is present at the current
level, the words of the value are joined with the first character of the
parameter <TT>$IFS</TT>, by default a space, between each word (single word
arrays are not modified).  If the <TT>(j)</TT> flag is present, that is used for
joining instead of <TT>$IFS</TT>.
<P>

</P>
<DT><TT>5.</TT> <EM>Nested Subscripting</EM>
<DD>Any remaining subscripts (i.e. of a nested substitution) are evaluated at
this point, based on whether the value is an array or a scalar.  As with
<TT>2.</TT>, multiple subscripts can appear.  Note that <TT>${foo[2,4][2]}</TT> is
thus equivalent to <TT>${${foo[2,4]}[2]}</TT> and also to
<TT>&quot;${${(@)foo[2,4]}[2]}&quot;</TT> (the nested substitution returns an array in
both cases), but not to <TT>&quot;${${foo[2,4]}[2]}&quot;</TT> (the nested substitution
returns a scalar because of the quotes).
<P>

</P>
<DT><TT>6.</TT> <EM>Modifiers</EM>
<DD>Any modifiers, as specified by a trailing `<TT>#</TT>', `<TT>%</TT>', `<TT>/</TT>'
(possibly doubled) or by a set of modifiers of the form <TT>:...</TT> (see
<A HREF="zsh_13.html#SEC45">13.1.4 Modifiers</A> in <A HREF="zsh_13.html#SEC41">13.1 History Expansion</A>), are applied to the words
of the value at this level.
<P>

</P>
<DT><TT>7.</TT> <EM>Forced Joining</EM>
<DD>If the `<TT>(j)</TT>' flag is present, or no `<TT>(j)</TT>' flag is present but
the string is to be split as given by rules <TT>8.</TT> or <TT>9.</TT>, and joining
did not take place at step <TT>4.</TT>, any words in the value are joined
together using the given string or the first character of <TT>$IFS</TT> if none.
Note that the `<TT>(F)</TT>' flag implicitly supplies a string for joining in this
manner.
<P>

</P>
<DT><TT>8.</TT> <EM>Forced Splitting</EM>
<DD>If one of the `<TT>(s)</TT>', `<TT>(f)</TT>' or `<TT>(z)</TT>' flags are present, or the `<TT>=</TT>'
specifier was present (e.g. <TT>${=</TT><VAR>var</VAR><TT>}</TT>), the word is split on
occurrences of the specified string, or (for <TT>=</TT> with neither of the two
flags present) any of the characters in <TT>$IFS</TT>.
<P>

</P>
<DT><TT>9.</TT> <EM>Shell Word Splitting</EM>
<DD>If no `<TT>(s)</TT>', `<TT>(f)</TT>' or `<TT>=</TT>' was given, but the word is not
quoted and the option <TT>SH_WORD_SPLIT</TT> is set, the word is split on
occurrences of any of the characters in <TT>$IFS</TT>.  Note this step, too,
takes place at all levels of a nested substitution.
<P>

</P>
<DT><TT>10.</TT> <EM>Re-Evaluation</EM>
<DD>Any `<TT>(e)</TT>' flag is applied to the value, forcing it to be re-examined
for new parameter substitutions, but also for command and arithmetic
substitutions.
<P>

</P>
<DT><TT>11.</TT> <EM>Padding</EM>
<DD>Any padding of the value by the `<TT>(l.</TT><VAR>fill</VAR><TT>.)</TT>' or
`<TT>(r.</TT><VAR>fill</VAR><TT>.)</TT>' flags is applied.
<P>

</P>
<DT><TT>12.</TT> <EM>Semantic Joining</EM>
<DD>In contexts where expansion semantics requires a single word to
result, all words are rejoined with the first character of <TT>IFS</TT>
between.  So in `<TT>${(P</TT><TT>)${(f</TT><TT>)lines}}</TT>'
the value of <TT>${lines}</TT> is split at newlines, but then must be
joined again before the <TT>P</TT> flag can be applied.
<P>

If a single word is not required, this rule is skipped.
</P>
<P>

</DL>
<P>

</P>
<P>

<HR SIZE="6">
<A NAME="SEC50"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC49"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC51"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC40"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC40"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_14.html#SEC63"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_24.html#SEC195">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 13.3.3 Examples </H3>
<!--docid::SEC50::-->
The flag <TT>f</TT> is useful to split a double-quoted substitution line by
line.  For example, <TT>${(f)&quot;$(&lt;</TT><VAR>file</VAR><TT>)&quot;}</TT>
substitutes the contents of <VAR>file</VAR> divided so that each line is
an element of the resulting array.  Compare this with the effect of
<TT>$</TT><TT>(&lt;</TT><VAR>file</VAR><TT>)</TT> alone, which divides the file
up by words, or the same inside double quotes, which makes the entire
content of the file a single string.
<P>

The following illustrates the rules for nested parameter expansions.
Suppose that <TT>$foo</TT> contains the array <TT>(bar baz</TT><TT>)</TT>:
</P>
<P>

</P>
<DL COMPACT>
<DT><TT>&quot;${(@)${foo}[1]}&quot;</TT>
<DD>This produces the result <TT>b</TT>.  First, the inner substitution
<TT>&quot;${foo}&quot;</TT>, which has no array (<TT>@</TT>) flag, produces a single word
result <TT>&quot;bar baz&quot;</TT>.  The outer substitution <TT>&quot;${(@)...[1]}&quot;</TT> detects
that this is a scalar, so that (despite the `<TT>(@)</TT>' flag) the subscript
picks the first character. 
<P>

</P>
<DT><TT>&quot;${${(@)foo}[1]}&quot;</TT>
<DD>This produces the result `<TT>bar</TT>'.  In this case, the inner substitution
<TT>&quot;${(@)foo}&quot;</TT> produces the array `<TT>(bar baz</TT><TT>)</TT>'.  The outer
substitution <TT>&quot;${...[1]}&quot;</TT> detects that this is an array and picks the
first word.  This is similar to the simple case <TT>&quot;${foo[1]}&quot;</TT>.
<P>

</DL>
<P>

As an example of the rules for word splitting and joining, suppose <TT>$foo</TT>
contains the array `<TT>(ax1 bx1</TT><TT>)</TT>'.  Then
</P>
<P>

</P>
<DL COMPACT>
<DT><TT>${(s/x/)foo}</TT>
<DD>produces the words `<TT>a</TT>', `<TT>1 b</TT>' and `<TT>1</TT>'.
<P>

</P>
<DT><TT>${(j/x/s/x/)foo}</TT>
<DD>produces `<TT>a</TT>', `<TT>1</TT>', `<TT>b</TT>' and `<TT>1</TT>'.
<P>

</P>
<DT><TT>${(s/x/)foo%%1*}</TT>
<DD>produces `<TT>a</TT>' and `<TT> b</TT>' (note the extra space).  As substitution
occurs before either joining or splitting, the operation  first generates
the modified array <TT>(ax bx</TT><TT>)</TT>, which is joined to give
<TT>&quot;ax bx&quot;</TT>, and then split to give `<TT>a</TT>', `<TT> b</TT>' and `'.  The final
empty string will then be elided, as it is not in double quotes.
<P>

</DL>
<P>

<A NAME="Command Substitution"></A>
</P>
<P>

<HR SIZE="6">
<A NAME="SEC51"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC50"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC52"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC40"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC40"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_14.html#SEC63"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_24.html#SEC195">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 13.4 Command Substitution </H2>
<!--docid::SEC51::-->
<A NAME="IDX168"></A>
<A NAME="IDX169"></A>
A command enclosed in parentheses preceded by a dollar sign, like
`<TT>$(</TT>...<TT>)</TT>', or quoted with grave 
accents, like `<TT>`</TT>...<TT>`</TT>', is replaced with its standard output, with
any trailing newlines deleted.
If the substitution is not enclosed in double quotes, the
output is broken into words using the <TT>IFS</TT> parameter.
<A NAME="IDX170"></A>
The substitution `<TT>$(cat</TT> <VAR>foo</VAR><TT>)</TT>' may be replaced
by the equivalent but faster `<TT>$(&lt;</TT><VAR>foo</VAR><TT>)</TT>'.
In either case, if the option <TT>GLOB_SUBST</TT> is set,
the output is eligible for filename generation.
<A NAME="Arithmetic Expansion"></A>
<P>

<HR SIZE="6">
<A NAME="SEC52"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC51"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC53"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC40"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC40"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_14.html#SEC63"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_24.html#SEC195">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 13.5 Arithmetic Expansion </H2>
<!--docid::SEC52::-->
<A NAME="IDX171"></A>
<A NAME="IDX172"></A>
A string of the form `<TT>$[</TT><VAR>exp</VAR><TT>]</TT>' or
`<TT>$((</TT><VAR>exp</VAR><TT>))</TT>' is substituted
with the value of the arithmetic expression <VAR>exp</VAR>.  <VAR>exp</VAR> is
subjected to <EM>parameter expansion</EM>, <EM>command substitution</EM>
and <EM>arithmetic expansion</EM> before it is evaluated.
See <A HREF="zsh_10.html#SEC37">10. Arithmetic Evaluation</A>.
<A NAME="Brace Expansion"></A>
<P>

<HR SIZE="6">
<A NAME="SEC53"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC52"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC54"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC40"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC40"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_14.html#SEC63"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_24.html#SEC195">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 13.6 Brace Expansion </H2>
<!--docid::SEC53::-->
<A NAME="IDX173"></A>
<A NAME="IDX174"></A>
A string of the form
`<VAR>foo</VAR><TT>{</TT><VAR>xx</VAR><TT>,</TT><VAR>yy</VAR><TT>,</TT><VAR>zz</VAR><TT>}</TT><VAR>bar</VAR>'
is expanded to the individual words
`<VAR>fooxxbar</VAR>', `<VAR>fooyybar</VAR>' and `<VAR>foozzbar</VAR>'.
Left-to-right order is preserved.  This construct
may be nested.  Commas may be quoted in order to
include them literally in a word.
<P>

An expression of the form `<TT>{</TT><VAR>n1</VAR><TT>..</TT><VAR>n2</VAR><TT>}</TT>',
where <VAR>n1</VAR> and <VAR>n2</VAR> are integers,
is expanded to every number between
<VAR>n1</VAR> and <VAR>n2</VAR> inclusive.  If either number begins with a
zero, all the resulting numbers will be padded with leading zeroes to
that minimum width.  If the numbers are in decreasing order the
resulting sequence will also be in decreasing order.
</P>
<P>

If a brace expression matches none of the above forms, it is left
unchanged, unless the <TT>BRACE_CCL</TT> option is set.
<A NAME="IDX175"></A>
In that case, it is expanded to a sorted list of the individual
characters between the braces, in the manner of a search set.
`<TT>-</TT>' is treated specially as in a search set, but `<TT>^</TT>' or `<TT>!</TT>' as
the first character is treated normally.
</P>
<P>

Note that brace expansion is not part of filename generation (globbing); an
expression such as <TT>*/{foo,bar}</TT> is split into two separate words
<TT>*/foo</TT> and <TT>*/bar</TT> before filename generation takes place.  In
particular, note that this is liable to produce a `no match' error if
<EM>either</EM> of the two expressions does not match; this is to be contrasted
with <TT>*/(foo|bar)</TT>, which is treated as a single pattern but otherwise
has similar effects.
<A NAME="Filename Expansion"></A>
</P>
<P>

<HR SIZE="6">
<A NAME="SEC54"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC53"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC55"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC40"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC40"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_14.html#SEC63"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_24.html#SEC195">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 13.7 Filename Expansion </H2>
<!--docid::SEC54::-->
<A NAME="IDX176"></A>
<A NAME="IDX177"></A>
Each word is checked to see if it begins with an unquoted `<TT>~</TT>'.
If it does, then the word up to a `<TT>/</TT>',
or the end of the word if there is no `<TT>/</TT>',
is checked to see if it can be substituted in one of the ways
described here.  If so, then the `<TT>~</TT>' and the checked portion are
replaced with the appropriate substitute value.
<P>

A `<TT>~</TT>' by itself is replaced by the value of <TT>$HOME</TT>.
A `<TT>~</TT>' followed by a `<TT>+</TT>' or a `<TT>-</TT>' is replaced by the value of
<TT>$PWD</TT> or <TT>$OLDPWD</TT>, respectively.
</P>
<P>

A `<TT>~</TT>' followed by a number is replaced by the directory at that
position in the directory stack.
`<TT>~0</TT>' is equivalent to `<TT>~+</TT>',
and `<TT>~1</TT>' is the top of the stack.
`<TT>~+</TT>' followed by a number is replaced by the directory at that
position in the directory stack.
`<TT>~+0</TT>' is equivalent to `<TT>~+</TT>',
and `<TT>~+1</TT>' is the top of the stack.
`<TT>~-</TT>' followed by a number is replaced by the directory that
many positions from the bottom of the stack.
`<TT>~-0</TT>' is the bottom of the stack.
<A NAME="IDX178"></A>
The <TT>PUSHD_MINUS</TT>
option exchanges the effects of `<TT>~+</TT>' and `<TT>~-</TT>' where they are
followed by a number.
</P>
<P>

<A NAME="IDX179"></A>
<A NAME="IDX180"></A>
A `<TT>~</TT>' followed by anything not already covered is looked up as a
named directory, and replaced by the value of that named directory if found.
Named directories are typically home directories for users on the system.
They may also be defined if the text after the `<TT>~</TT>' is the name
of a string shell parameter whose value begins with a `<TT>/</TT>'.
It is also possible to define directory names using the <TT>-d</TT> option to the
<TT>hash</TT> builtin.
</P>
<P>

In certain circumstances (in prompts, for instance), when the shell
prints a path, the path is checked to see if it has a named
directory as its prefix.  If so, then the prefix portion
is replaced with a `<TT>~</TT>' followed by the name of the directory.
The shortest way of referring to the directory is used,
with ties broken in favour of using a named directory,
except when the directory is <TT>/</TT> itself.  The parameters <TT>$PWD</TT> and
<TT>$OLDPWD</TT> are never abbreviated in this fashion.
</P>
<P>

If a word begins with an unquoted `<TT>=</TT>'
and the <TT>EQUALS</TT> option is set,
the remainder of the word is taken as the
name of a command or alias.  If a command
exists by that name, the word is replaced
by the full pathname of the command.
If an alias exists by that name, the word
is replaced with the text of the alias.
</P>
<P>

Filename expansion is performed on the right hand side of a parameter
assignment, including those appearing after commands of the
<TT>typeset</TT> family.  In this case, the right hand side will be treated
as a colon-separated list in the manner of the <TT>PATH</TT> parameter,
so that a `<TT>~</TT>' or an `<TT>=</TT>' following a `<TT>:</TT>' is eligible for expansion.
All such behaviour can be
disabled by quoting the `<TT>~</TT>', the `<TT>=</TT>', or the whole expression (but not
simply the colon); the <TT>EQUALS</TT> option is also respected.
</P>
<P>

If the option <TT>MAGIC_EQUAL_SUBST</TT> is set, any unquoted shell
argument in the form `<VAR>identifier</VAR><TT>=</TT><VAR>expression</VAR>' becomes eligible
for file expansion as described in the previous paragraph.  Quoting the
first `<TT>=</TT>' also inhibits this.
<A NAME="Filename Generation"></A>
</P>
<P>

<HR SIZE="6">
<A NAME="SEC55"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC54"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC56"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC40"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC40"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_14.html#SEC63"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_24.html#SEC195">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 13.8 Filename Generation </H2>
<!--docid::SEC55::-->
<A NAME="IDX181"></A>
If a word contains an unquoted instance of one of the characters
`<TT>*</TT>', `<TT>(</TT>', `<TT>|</TT>', `<TT>&lt;</TT>', `<TT>[</TT>', or `<TT>?</TT>', it is regarded
as a pattern for filename generation, unless the <TT>GLOB</TT> option is unset.
<A NAME="IDX182"></A>
If the <TT>EXTENDED_GLOB</TT> option is set,
<A NAME="IDX183"></A>
the `<TT>^</TT>' and `<TT>#</TT>' characters also denote a pattern; otherwise
they are not treated specially by the shell.
<P>

The word is replaced with a list of sorted filenames that match
the pattern.  If no matching pattern is found, the shell gives
an error message, unless the <TT>NULL_GLOB</TT> option is set,
<A NAME="IDX184"></A>
in which case the word is deleted; or unless the <TT>NOMATCH</TT>
option is unset, in which case the word is left unchanged.
<A NAME="IDX185"></A>
</P>
<P>

In filename generation,
the character `<TT>/</TT>' must be matched explicitly;
also, a `<TT>.</TT>' must be matched
explicitly at the beginning of a pattern or after a `<TT>/</TT>', unless the
<TT>GLOB_DOTS</TT> option is set.
<A NAME="IDX186"></A>
No filename generation pattern
matches the files `<TT>.</TT>' or `<TT>..</TT>'.  In other instances of pattern
matching, the `<TT>/</TT>' and `<TT>.</TT>' are not treated specially.
</P>
<P>

<HR SIZE="6">
<A NAME="SEC56"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC55"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC57"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC40"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC40"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_14.html#SEC63"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_24.html#SEC195">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 13.8.1 Glob Operators </H3>
<!--docid::SEC56::-->
<DL COMPACT>
<DT><TT>*</TT>
<DD>Matches any string, including the null string.
<P>

</P>
<DT><TT>?</TT>
<DD>Matches any character.
<P>

</P>
<DT><TT>[</TT>...<TT>]</TT>
<DD>Matches any of the enclosed characters.  Ranges of characters
can be specified by separating two characters by a `<TT>-</TT>'.
A `<TT>-</TT>' or `<TT>]</TT>' may be matched by including it as the
first character in the list.
<A NAME="IDX187"></A>
There are also several named classes of characters, in the form
`<TT>[:</TT><VAR>name</VAR><TT>:]</TT>' with the following meanings:  `<TT>[:alnum:]</TT>'
alphanumeric, `<TT>[:alpha:]</TT>' alphabetic,
`<TT>[:blank:]</TT>' space or tab,
`<TT>[:cntrl:]</TT>' control character, `<TT>[:digit:]</TT>' decimal
digit, `<TT>[:graph:]</TT>' printable character except whitespace,
`<TT>[:lower:]</TT>' lowercase letter, `<TT>[:print:]</TT>' printable character,
`<TT>[:punct:]</TT>' printable character neither alphanumeric nor whitespace,
`<TT>[:space:]</TT>' whitespace character, `<TT>[:upper:]</TT>' uppercase letter, 
`<TT>[:xdigit:]</TT>' hexadecimal digit.  These use the macros provided by
the operating system to test for the given character combinations,
including any modifications due to local language settings:  see
man page ctype(3).  Note that the square brackets are additional
to those enclosing the whole set of characters, so to test for a
single alphanumeric character you need `<TT>[[:alnum:]]</TT>'.  Named
character sets can be used alongside other types,
e.g. `<TT>[[:alpha:]0-9]</TT>'.
<P>

</P>
<DT><TT>[^</TT>...<TT>]</TT>
<DD><DT><TT>[!</TT>...<TT>]</TT>
<DD>Like <TT>[</TT>...<TT>]</TT>, except that it matches any character which is
not in the given set.
<P>

</P>
<DT><TT>&lt;</TT>[<VAR>x</VAR>]<TT>-</TT>[<VAR>y</VAR>]<TT>&gt;</TT>
<DD>Matches any number in the range <VAR>x</VAR> to <VAR>y</VAR>, inclusive.
Either of the numbers may be omitted to make the range open-ended;
hence `<TT>&lt;-&gt;</TT>' matches any number.  To match individual digits, the
<TT>[</TT>...<TT>]</TT> form is more efficient.
<P>

Be careful when using other wildcards adjacent to patterns of this form;
for example, <TT>&lt;0-9&gt;*</TT> will actually match any number whatsoever at the
start of the string, since the `<TT>&lt;0-9&gt;</TT>' will match the first digit, and
the `<TT>*</TT>' will match any others.  This is a trap for the unwary, but is
in fact an inevitable consequence of the rule that the longest possible
match always succeeds.  Expressions such as `<TT>&lt;0-9&gt;[^[:digit:]]*</TT>' can be
used instead.
</P>
<P>

</P>
<DT><TT>(</TT>...<TT>)</TT>
<DD>Matches the enclosed pattern.  This is used for grouping.
If the <TT>KSH_GLOB</TT> option is set, then a
`<TT>@</TT>', `<TT>*</TT>', `<TT>+</TT>', `<TT>?</TT>' or `<TT>!</TT>' immediately preceding
the `<TT>(</TT>' is treated specially, as detailed below. The option
<TT>SH_GLOB</TT> prevents bare parentheses from being used in this way, though
the <TT>KSH_GLOB</TT> option is still available.
<P>

Note that grouping cannot extend over multiple directories: it is an error
to have a `<TT>/</TT>' within a group (this only applies for patterns used in
filename generation).  There is one exception:  a group of the form
<TT>(</TT><VAR>pat</VAR><TT>/)#</TT> appearing as a complete path segment can
match a sequence of directories.  For example, <TT>foo/(a*/)#bar</TT> matches
<TT>foo/bar</TT>, <TT>foo/any/bar</TT>, <TT>foo/any/anyother/bar</TT>, and so on.
</P>
<P>

</P>
<DT><VAR>x</VAR><TT>|</TT><VAR>y</VAR>
<DD>Matches either <VAR>x</VAR> or <VAR>y</VAR>.
This operator has lower precedence than any other.
The `<TT>|</TT>' character
must be within parentheses, to avoid interpretation as a pipeline.
<P>

</P>
<DT><TT>^</TT><VAR>x</VAR>
<DD>(Requires <TT>EXTENDED_GLOB</TT> to be set.)
Matches anything except the pattern <VAR>x</VAR>.
This has a higher precedence than `<TT>/</TT>', so `<TT>^foo/bar</TT>'
will search directories in `<TT>.</TT>' except `<TT>./foo</TT>'
for a file named `<TT>bar</TT>'.
<P>

</P>
<DT><VAR>x</VAR><TT>~</TT><VAR>y</VAR>
<DD>(Requires <TT>EXTENDED_GLOB</TT> to be set.)
Match anything that matches the pattern <VAR>x</VAR> but does not match <VAR>y</VAR>.
This has lower precedence than any operator except `<TT>|</TT>', so
`<TT>*/*~foo/bar</TT>' will search for all files in all directories in `<TT>.</TT>'
and then exclude `<TT>foo/bar</TT>' if there was such a match.
Multiple patterns can be excluded by
`<VAR>foo</VAR><TT>~</TT><VAR>bar</VAR><TT>~</TT><VAR>baz</VAR>'.
In the exclusion pattern (<VAR>y</VAR>), `<TT>/</TT>' and `<TT>.</TT>' are not treated
specially the way they usually are in globbing.
<P>

</P>
<DT><VAR>x</VAR><TT>#</TT>
<DD>(Requires <TT>EXTENDED_GLOB</TT> to be set.)
Matches zero or more occurrences of the pattern <VAR>x</VAR>.
This operator has high precedence; `<TT>12#</TT>' is equivalent to `<TT>1(2#)</TT>',
rather than `<TT>(12)#</TT>'.  It is an error for an unquoted `<TT>#</TT>' to follow
something which cannot be repeated; this includes an empty string, a
pattern already followed by `<TT>##</TT>', or parentheses when part of a
<TT>KSH_GLOB</TT> pattern (for example, `<TT>!(</TT><VAR>foo</VAR><TT>)#</TT>' is
invalid and must be replaced by
`<TT>*(!(</TT><VAR>foo</VAR><TT>))</TT>').
<P>

</P>
<DT><VAR>x</VAR><TT>##</TT>
<DD>(Requires <TT>EXTENDED_GLOB</TT> to be set.)
Matches one or more occurrences of the pattern <VAR>x</VAR>.
This operator has high precedence; `<TT>12##</TT>' is equivalent to `<TT>1(2##)</TT>',
rather than `<TT>(12)##</TT>'.  No more than two active `<TT>#</TT>' characters may
appear together.
<P>

</DL>
<P>

<HR SIZE="6">
<A NAME="SEC57"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC56"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC58"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC40"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC40"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_14.html#SEC63"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_24.html#SEC195">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 13.8.2 ksh-like Glob Operators </H3>
<!--docid::SEC57::-->
<A NAME="IDX188"></A>
If the <TT>KSH_GLOB</TT> option is set, the effects of parentheses can be
modified by a preceding `<TT>@</TT>', `<TT>*</TT>', `<TT>+</TT>', `<TT>?</TT>' or `<TT>!</TT>'.
This character need not be unquoted to have special effects,
but the `<TT>(</TT>' must be.
<P>

</P>
<DL COMPACT>
<DT><TT>@(</TT>...<TT>)</TT>
<DD>Match the pattern in the parentheses.  (Like `<TT>(</TT>...<TT>)</TT>'.)
<P>

</P>
<DT><TT>*(</TT>...<TT>)</TT>
<DD>Match any number of occurrences.  (Like `<TT>(</TT>...<TT>)#</TT>'.)
<P>

</P>
<DT><TT>+(</TT>...<TT>)</TT>
<DD>Match at least one occurrence.  (Like `<TT>(</TT>...<TT>)##</TT>'.)
<P>

</P>
<DT><TT>?(</TT>...<TT>)</TT>
<DD>Match zero or one occurrence.  (Like `<TT>(|</TT>...<TT>)</TT>'.)
<P>

</P>
<DT><TT>!(</TT>...<TT>)</TT>
<DD>Match anything but the expression in parentheses.
(Like `<TT>(^(</TT>...<TT>))</TT>'.)
<P>

</DL>
<P>

<HR SIZE="6">
<A NAME="SEC58"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC57"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC59"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC40"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC40"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_14.html#SEC63"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_24.html#SEC195">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 13.8.3 Precedence </H3>
<!--docid::SEC58::-->
<A NAME="IDX189"></A>
The precedence of the operators given above is (highest) `<TT>^</TT>', `<TT>/</TT>',
`<TT>~</TT>', `<TT>|</TT>' (lowest); the
remaining operators are simply treated from left to right as part of a
string, with `<TT>#</TT>' and `<TT>##</TT>' applying to the shortest possible
preceding unit (i.e. a character, `<TT>?</TT>', `<TT>[</TT>...<TT>]</TT>',
`<TT>&lt;</TT>...<TT>&gt;</TT>', or a parenthesised expression).  As mentioned
above, a `<TT>/</TT>' used as a directory separator may not appear inside
parentheses, while a `<TT>|</TT>' must do so; in patterns used in other contexts
than filename generation (for example, in <TT>case</TT> statements and tests
within `<TT>[[</TT>...<TT>]]</TT>'), a `<TT>/</TT>' is not special; and `<TT>/</TT>' is also
not special after a `<TT>~</TT>' appearing outside parentheses in a filename
pattern.
<P>

<HR SIZE="6">
<A NAME="SEC59"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC58"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC60"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC40"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC40"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_14.html#SEC63"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_24.html#SEC195">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 13.8.4 Globbing Flags </H3>
<!--docid::SEC59::-->
There are various flags which affect any text to their right up to the
end of the enclosing group or to the end of the pattern; they require
the <TT>EXTENDED_GLOB</TT> option. All take the form
<TT>(#</TT><VAR>X</VAR><TT>)</TT> where <VAR>X</VAR> may have one of the following
forms:
<P>

</P>
<DL COMPACT>
<DT>i
<DD>Case insensitive:  upper or lower case characters in the pattern match
upper or lower case characters.
<P>

</P>
<DT>l
<DD>Lower case characters in the pattern match upper or lower case
characters; upper case characters in the pattern still only match
upper case characters.
<P>

</P>
<DT>I
<DD>Case sensitive:  locally negates the effect of <TT>i</TT> or <TT>l</TT> from
that point on.
<P>

</P>
<DT>b
<DD>Activate backreferences for parenthesised groups in the pattern;
this does not work in filename generation.  When a pattern with a set of
active parentheses is matched, the strings matched by the groups are
stored in the array <TT>$match</TT>, the indices of the beginning of the matched
parentheses in the array <TT>$mbegin</TT>, and the indices of the end in the array
<TT>$mend</TT>, with the first element of each array corresponding to the first
parenthesised group, and so on.  These arrays are not otherwise special to
the shell.  The indices use the same convention as does parameter
substitution, so that elements of <TT>$mend</TT> and <TT>$mbegin</TT> may be used in
subscripts; the <TT>KSH_ARRAYS</TT> option is respected.  Sets of globbing flags
are not considered parenthesised groups; only the first nine active
parentheses can be referenced.
<P>

For example,
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>foo=&quot;a string with a message&quot;
if [[ $foo = (a|an)' '(#b)(*)' '* ]]; then
  print ${foo[$mbegin[1],$mend[1]]}
fi
</pre></td></tr></table><P>

prints `<TT>string with a</TT>'.  Note that the first parenthesis is before the
<TT>(#b)</TT> and does not create a backreference.
</P>
<P>

Backreferences work with all forms of pattern matching other than filename
generation, but note that when performing matches on an entire array, such
as <TT>${</TT><VAR>array</VAR><TT>#</TT><VAR>pattern</VAR><TT>}</TT>, or a global substitution, such
as <TT>${</TT><VAR>param</VAR><TT>//</TT><VAR>pat</VAR><TT>/</TT><VAR>repl</VAR><TT>}</TT>, only the data for the
last match remains available.  In the case of global replacements this may
still be useful.  See the example for the <TT>m</TT> flag below.
</P>
<P>

The numbering of backreferences strictly follows the order of the opening
parentheses from left to right in the pattern string, although sets of
parentheses may be nested.  There are special rules for parentheses followed
by `<TT>#</TT>' or `<TT>##</TT>'.  Only the last match of the parenthesis is
remembered: for example, in `<TT>[[ abab = (#b)([ab])# ]]</TT>', only the final
`<TT>b</TT>' is stored in <TT>match[1]</TT>.  Thus extra parentheses may be necessary
to match the complete segment: for example, use `<TT>X((ab|cd)#)Y</TT>' to match
a whole string of either `<TT>ab</TT>' or `<TT>cd</TT>' between `<TT>X</TT>' and `<TT>Y</TT>',
using the value of <TT>$match[1]</TT> rather than <TT>$match[2]</TT>.
</P>
<P>

If the match fails none of the parameters is altered, so in some cases it
may be necessary to initialise them beforehand.  If some of the
backreferences fail to match -- which happens if they are in an alternate
branch which fails to match, or if they are followed by <TT>#</TT> and matched
zero times -- then the matched string is set to the empty string, and the
start and end indices are set to -1.
</P>
<P>

Pattern matching with backreferences is slightly slower than without.
</P>
<P>

</P>
<DT>B
<DD>Deactivate backreferences, negating the effect of the <TT>b</TT> flag from that
point on.
<P>

</P>
<DT>m
<DD>Set references to the match data for the entire string matched; this is
similar to backreferencing and does not work in filename generation.  The
flag must be in effect at the end of the pattern, i.e. not local to a
group. The parameters <TT>$MATCH</TT>,  <TT>$MBEGIN</TT> and <TT>$MEND</TT> will be set to
the string matched and to the indices of the beginning and end of the
string, respectively.  This is most useful in parameter substitutions, as
otherwise the string matched is obvious.
<P>

For example,
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>arr=(veldt jynx grimps waqf zho buck)
print ${arr//(#m)[aeiou]/${(U)MATCH}}
</pre></td></tr></table><P>

forces all the matches (i.e. all vowels) into uppercase, printing
`<TT>vEldt jynx grImps wAqf zhO bUck</TT>'.
</P>
<P>

Unlike backreferences, there is no speed penalty for using match
references, other than the extra substitutions required for the
replacement strings in cases such as the example shown.
</P>
<P>

</P>
<DT>M
<DD>Deactivate the <TT>m</TT> flag, hence no references to match data will be
created.
<P>

</P>
<DT><TT>a</TT><VAR>num</VAR>
<DD>Approximate matching: <VAR>num</VAR> errors are allowed in the string matched by
the pattern.  The rules for this are described in the next subsection.
<P>

</P>
<DT><TT>s</TT>, <TT>e</TT>
<DD>Unlike the other flags, these have only a local effect, and each must
appear on its own:  `<TT>(#s)</TT>' and `<TT>(#e)</TT>' are the only valid forms.
The `<TT>(#s)</TT>' flag succeeds only at the start of the test string, and the
`<TT>(#e)</TT>' flag succeeds only at the end of the test string; they
correspond to `<TT>^</TT>' and `<TT>$</TT>' in standard regular expressions.  They
are useful for matching path segments in patterns other than those in
filename generation (where path segments are in any case treated
separately).  For example, `<TT>*((#s)|/)test((#e)|/)*</TT>' matches a path
segment `<TT>test</TT>' in any of the following strings: <TT>test</TT>,
<TT>test/at/start</TT>, <TT>at/end/test</TT>, <TT>in/test/middle</TT>.
<P>

Another use is in parameter substitution; for example
`<TT>${array/(#s)A*Z(#e)}</TT>' will remove only elements of an array which
match the complete pattern `<TT>A*Z</TT>'.  There are other ways of performing
many operations of this type, however the combination of the substitution
operations `<TT>/</TT>' and `<TT>//</TT>' with the `<TT>(#s)</TT>' and `<TT>(#e)</TT>' flags
provides a single simple and memorable method.
</P>
<P>

Note that assertions of the form `<TT>(^(#s))</TT>' also work, i.e. match
anywhere except at the start of the string, although this actually means
`anything except a zero-length portion at the start of the string'; you
need to use `<TT>(&quot;&quot;~(#s))</TT>' to match a zero-length portion of the string
not at the start.
</P>
<P>

</DL>
<P>

For example, the test string <TT>fooxx</TT> can be matched by the pattern
<TT>(#i</TT><TT>)FOOXX</TT>, but not by <TT>(#l</TT><TT>)FOOXX</TT>,
<TT>(#i</TT><TT>)FOO</TT><TT>(#I</TT><TT>)XX</TT> or
<TT>((#i</TT><TT>)FOOX</TT><TT>)X</TT>.  The string
<TT>(#ia2</TT><TT>)readme</TT> specifies case-insensitive matching of
<TT>readme</TT> with up to two errors.
</P>
<P>

When using the ksh syntax for grouping both <TT>KSH_GLOB</TT> and
<TT>EXTENDED_GLOB</TT> must be set and the left parenthesis should be
preceded by <TT>@</TT>.  Note also that the flags do not affect letters
inside <TT>[...]</TT> groups, in other words <TT>(#i</TT><TT>)[a-z]</TT>
still matches only lowercase letters.  Finally, note that when
examining whole paths case-insensitively every directory must be
searched for all files which match, so that a pattern of the form
<TT>(#i</TT><TT>)/foo/bar/...</TT> is potentially slow.
</P>
<P>

</P>
<P>

<HR SIZE="6">
<A NAME="SEC60"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC59"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC61"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC40"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC40"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_14.html#SEC63"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_24.html#SEC195">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 13.8.5 Approximate Matching </H3>
<!--docid::SEC60::-->
When matching approximately, the shell keeps a count of the errors found,
which cannot exceed the number specified in the
<TT>(#a</TT><VAR>num</VAR><TT>)</TT> flags.  Four types of error are recognised:
<P>

</P>
<DL COMPACT>
<DT>1.
<DD>Different characters, as in <TT>fooxbar</TT> and <TT>fooybar</TT>.
<P>

</P>
<DT>2.
<DD>Transposition of characters, as in <TT>banana</TT> and <TT>abnana</TT>.
<P>

</P>
<DT>3.
<DD>A character missing in the target string, as with the pattern <TT>road</TT> and
target string <TT>rod</TT>.
<P>

</P>
<DT>4.
<DD>An extra character appearing in the target string, as with <TT>stove</TT>
and <TT>strove</TT>.
<P>

</DL>
<P>

Thus, the pattern <TT>(#a3</TT><TT>)abcd</TT> matches <TT>dcba</TT>, with the
errors occurring by using the first rule twice and the second once,
grouping the string as <TT>[d][cb][a]</TT> and <TT>[a][bc][d]</TT>.
</P>
<P>

Non-literal parts of the pattern must match exactly, including characters
in character ranges: hence <TT>(#a1</TT><TT>)???</TT>  matches strings of
length four, by applying rule 4 to an empty part of the pattern, but not
strings of length two, since all the <TT>?</TT> must match.  Other characters
which must match exactly are initial dots in filenames (unless the
<TT>GLOB_DOTS</TT> option is set), and all slashes in filenames, so that
<TT>a/bc</TT> is two errors from <TT>ab/c</TT> (the slash cannot be transposed with
another character).  Similarly, errors are counted separately for
non-contiguous strings in the pattern, so that <TT>(ab|cd</TT><TT>)ef</TT>
is two errors from <TT>aebf</TT>.
</P>
<P>

When using exclusion via the <TT>~</TT> operator, approximate matching is
treated entirely separately for the excluded part and must be activated
separately.  Thus, <TT>(#a1</TT><TT>)README~READ_ME</TT> matches
<TT>READ.ME</TT> but not <TT>READ_ME</TT>, as the trailing <TT>READ_ME</TT> is matched
without approximation.  However,
<TT>(#a1</TT><TT>)README~(#a1</TT><TT>)READ_ME</TT>
does not match any pattern of the form <TT>READ</TT><VAR>?</VAR><TT>ME</TT> as all
such forms are now excluded.
</P>
<P>

Apart from exclusions, there is only one overall error count; however, the
maximum errors allowed may be altered locally, and this can be delimited by
grouping.  For example,
<TT>(#a1</TT><TT>)cat</TT><TT>((#a0</TT><TT>)dog</TT><TT>)fox</TT>
allows one error in total, which may not occur in the <TT>dog</TT> section, and
the pattern
<TT>(#a1</TT><TT>)cat</TT><TT>(#a0</TT><TT>)dog</TT><TT>(#a1</TT><TT>)fox</TT>
is equivalent.  Note that the point at which an error is first found is the
crucial one for establishing whether to use approximation; for example,
<TT>(#a1)abc(#a0)xyz</TT> will not match <TT>abcdxyz</TT>, because the error occurs
at the `<TT>x</TT>', where approximation is turned off.
</P>
<P>

Entire path segments may be matched approximately, so that
`<TT>(#a1)/foo/d/is/available/at/the/bar</TT>' allows one error in any path
segment.  This is much less efficient than without the <TT>(#a1)</TT>, however,
since every directory in the path must be scanned for a possible
approximate match.  It is best to place the <TT>(#a1)</TT> after any path
segments which are known to be correct.
</P>
<P>

</P>
<P>

<HR SIZE="6">
<A NAME="SEC61"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC60"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC62"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC40"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC40"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_14.html#SEC63"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_24.html#SEC195">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 13.8.6 Recursive Globbing </H3>
<!--docid::SEC61::-->
A pathname component of the form `<TT>(</TT><VAR>foo</VAR><TT>/)#</TT>'
matches a path consisting of zero or more directories
matching the pattern <VAR>foo</VAR>.
<P>

As a shorthand, `<TT>**/</TT>' is equivalent to `<TT>(*/)#</TT>'; note that this
therefore matches files in the current directory as well as
subdirectories.
Thus:
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>ls (*/)#bar
</pre></td></tr></table><P>

or
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>ls **/bar
</pre></td></tr></table><P>

does a recursive directory search for files named `<TT>bar</TT>' (potentially
including the file `<TT>bar</TT>' in the current directory).  This form does not
follow symbolic links; the alternative form `<TT>***/</TT>' does, but is
otherwise identical.  Neither of these can be combined with other forms of
globbing within the same path segment; in that case, the `<TT>*</TT>'
operators revert to their usual effect.
</P>
<P>

<HR SIZE="6">
<A NAME="SEC62"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC61"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_14.html#SEC63"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC40"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC40"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_14.html#SEC63"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_24.html#SEC195">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 13.8.7 Glob Qualifiers </H3>
<!--docid::SEC62::-->
<A NAME="IDX190"></A>
<A NAME="IDX191"></A>
Patterns used for filename generation may end in a
list of qualifiers enclosed in parentheses.
The qualifiers specify which filenames that otherwise match the given pattern
will be inserted in the argument list.
<P>

<A NAME="IDX192"></A>
If the option <TT>BARE_GLOB_QUAL</TT> is set, then a trailing set of parentheses
containing no `<TT>|</TT>' or `<TT>(</TT>' characters (or `<TT>~</TT>' if it is special)
is taken as a set of
glob qualifiers.  A glob subexpression that would normally be taken as glob
qualifiers, for example `<TT>(^x)</TT>', can be forced to be treated as part of
the glob pattern by doubling the parentheses, in this case producing
`<TT>((^x))</TT>'.
</P>
<P>

A qualifier may be any one of the following:
</P>
<P>

</P>
<DL COMPACT>
<DT><TT>/</TT>
<DD>directories
<P>

</P>
<DT><TT>.</TT>
<DD>plain files
<P>

</P>
<DT><TT>@</TT>
<DD>symbolic links
<P>

</P>
<DT><TT>=</TT>
<DD>sockets
<P>

</P>
<DT><TT>p</TT>
<DD>named pipes (FIFOs)
<P>

</P>
<DT><TT>*</TT>
<DD>executable plain files (0100)
<P>

</P>
<DT><TT>%</TT>
<DD>device files (character or block special)
<P>

</P>
<DT><TT>%b</TT>
<DD>block special files
<P>

</P>
<DT><TT>%c</TT>
<DD>character special files
<P>

</P>
<DT><TT>r</TT>
<DD>owner-readable files (0400)
<P>

</P>
<DT><TT>w</TT>
<DD>owner-writable files (0200)
<P>

</P>
<DT><TT>x</TT>
<DD>owner-executable files (0100)
<P>

</P>
<DT><TT>A</TT>
<DD>group-readable files (0040)
<P>

</P>
<DT><TT>I</TT>
<DD>group-writable files (0020)
<P>

</P>
<DT><TT>E</TT>
<DD>group-executable files (0010)
<P>

</P>
<DT><TT>R</TT>
<DD>world-readable files (0004)
<P>

</P>
<DT><TT>W</TT>
<DD>world-writable files (0002)
<P>

</P>
<DT><TT>X</TT>
<DD>world-executable files (0001)
<P>

</P>
<DT><TT>s</TT>
<DD>setuid files (04000)
<P>

</P>
<DT><TT>S</TT>
<DD>setgid files (02000)
<P>

</P>
<DT><TT>t</TT>
<DD>files with the sticky bit (01000)
<P>

</P>
<DT><TT>f</TT><VAR>spec</VAR>
<DD>files with access rights matching <VAR>spec</VAR>. This <VAR>spec</VAR> may be a
octal number optionally preceded by a `<TT>=</TT>', a `<TT>+</TT>', or a
`<TT>-</TT>'. If none of these characters is given, the behavior is the
same as for `<TT>=</TT>'. The octal number describes the mode bits to be
expected, if combined with a `<TT>=</TT>', the value given must match the
file-modes exactly, with a `<TT>+</TT>', at least the bits in the
given number must be set in the file-modes, and with a `<TT>-</TT>', the
bits in the number must not be set. Giving a `<TT>?</TT>' instead of a
octal digit anywhere in the number ensures that the corresponding bits 
in the file-modes are not checked, this is only useful in combination
with `<TT>=</TT>'.
<P>

If the qualifier `<TT>f</TT>' is followed by any other character anything
up to the next matching character (`<TT>[</TT>', `<TT>{</TT>', and `<TT>&lt;</TT>' match 
`<TT>]</TT>', `<TT>}</TT>', and `<TT>&gt;</TT>' respectively, any other character
matches itself) is taken as a list of comma-separated
<VAR>sub-spec</VAR>s. Each <VAR>sub-spec</VAR> may be either an octal number as
described above or a list of any of the characters `<TT>u</TT>', `<TT>g</TT>',
`<TT>o</TT>', and `<TT>a</TT>', followed by a `<TT>=</TT>', a `<TT>+</TT>', or a
`<TT>-</TT>', followed by a list of any of the characters `<TT>r</TT>', `<TT>w</TT>', 
`<TT>x</TT>', `<TT>s</TT>', and `<TT>t</TT>', or an octal digit. The first list of
characters specify which access rights are to be checked. If a `<TT>u</TT>'
is given, those for the owner of the file are used, if a `<TT>g</TT>' is
given, those of the group are checked, a `<TT>o</TT>' means to test those
of other users, and the `<TT>a</TT>' says to test all three groups. The
`<TT>=</TT>', `<TT>+</TT>', and `<TT>-</TT>' again says how the modes are to be
checked and have the same meaning as described for the first form
above. The second list of characters finally says which access rights
are to be expected: `<TT>r</TT>' for read access, `<TT>w</TT>' for write access, 
`<TT>x</TT>' for the right to execute the file (or to search a directory),
`<TT>s</TT>' for the setuid and setgid bits, and `<TT>t</TT>' for the sticky
bit.
</P>
<P>

Thus, `<TT>*(f70?)</TT>' gives the files for which the owner has read,
write, and execute permission, and for which other group members have
no rights, independent of the permissions for other users. The pattern
`<TT>*(f-100)</TT>' gives all files for which the owner does not have
execute permission, and `<TT>*(f:gu+w,o-rx:)</TT>' gives the files for which 
the owner and the other members of the group have at least write
permission, and for which other users don't have read or execute
permission.
</P>
<P>

</P>
<DT><TT>e</TT><VAR>string</VAR>
<DD>The <VAR>string</VAR> will be executed as shell code.  The filename will be
included in the list if and only if the code returns a zero status (usually
the status of the last command).  The first character after the `<TT>e</TT>'
will be used as a separator and anything up to the next matching separator
will be taken  as the <VAR>string</VAR>; `<TT>[</TT>', `<TT>{</TT>', and `<TT>&lt;</TT>' match
`<TT>]</TT>', `<TT>}</TT>', and `<TT>&gt;</TT>', respectively, while any other character
matches itself. Note that expansions must be quoted in the <VAR>string</VAR>
to prevent them from being expanded before globbing is done.
<P>

<A NAME="IDX193"></A>
<A NAME="IDX194"></A>
During the execution of <VAR>string</VAR> the filename currently being tested is
available in the parameter <TT>REPLY</TT>; the parameter may be altered to
a string to be inserted into the list instead of the original
filename.  In addition, the parameter <TT>reply</TT> may be set to an array or a
string, which overrides the value of <TT>REPLY</TT>.  If set to an array, the
latter is inserted into the command line word by word.
</P>
<P>

For example, suppose a directory contains a single file `<TT>lonely</TT>'.  Then
the expression `<TT>*(e:'reply=(${REPLY}{1,2})':)</TT>' will cause the words
`<TT>lonely1 lonely2</TT>' to be inserted into the command line.  Note the
quotation marks.
</P>
<P>

</P>
<DT><TT>d</TT><VAR>dev</VAR>
<DD>files on the device <VAR>dev</VAR>
<P>

</P>
<DT><TT>l</TT>[<TT>-</TT>|<TT>+</TT>]<VAR>ct</VAR>
<DD>files having a link count less than <VAR>ct</VAR> (<TT>-</TT>), greater than
<VAR>ct</VAR> (<TT>+</TT>), or equal to <VAR>ct</VAR>
<P>

</P>
<DT><TT>U</TT>
<DD>files owned by the effective user ID
<P>

</P>
<DT><TT>G</TT>
<DD>files owned by the effective group ID
<P>

</P>
<DT><TT>u</TT><VAR>id</VAR>
<DD>files owned by user ID <VAR>id</VAR> if it is a number, if not, than the
character after the `<TT>u</TT>' will be used as a separator and the string
between it and the next matching separator
(`<TT>[</TT>', `<TT>{</TT>', and `<TT>&lt;</TT>'
match `<TT>]</TT>', `<TT>}</TT>', and `<TT>&gt;</TT>' respectively,
any other character matches
itself) will be taken as a user name, and the user ID of this user will
be taken (e.g. `<TT>u:foo:</TT>' or `<TT>u[foo]</TT>' for user `<TT>foo</TT>')
<P>

</P>
<DT><TT>g</TT><VAR>id</VAR>
<DD>like <TT>u</TT><VAR>id</VAR> but with group IDs or names
<P>

</P>
<DT><TT>a</TT>[<TT>Mwhms</TT>][<TT>-</TT>|<TT>+</TT>]<VAR>n</VAR>
<DD>files accessed exactly <VAR>n</VAR> days ago.  Files accessed within the last
<VAR>n</VAR> days are selected using a negative value for <VAR>n</VAR> (<TT>-</TT><VAR>n</VAR>).
Files accessed more than <VAR>n</VAR> days ago are selected by a positive <VAR>n</VAR>
value (<TT>+</TT><VAR>n</VAR>).  Optional unit specifiers `<TT>M</TT>', `<TT>w</TT>',
`<TT>h</TT>', `<TT>m</TT>' or `<TT>s</TT>' (e.g. `<TT>ah5</TT>') cause the check to be
performed with months (of 30 days), weeks, hours, minutes or seconds
instead of days, respectively.  For instance, `<TT>echo *(ah-5)</TT>' would
echo files accessed within the last five hours.
<P>

</P>
<DT><TT>m</TT>[<TT>Mwhms</TT>][<TT>-</TT>|<TT>+</TT>]<VAR>n</VAR>
<DD>like the file access qualifier, except that it uses the file modification
time.
<P>

</P>
<DT><TT>c</TT>[<TT>Mwhms</TT>][<TT>-</TT>|<TT>+</TT>]<VAR>n</VAR>
<DD>like the file access qualifier, except that it uses the file inode change
time.
<P>

</P>
<DT><TT>L</TT>[<TT>+</TT>|<TT>-</TT>]<VAR>n</VAR>
<DD>files less than <VAR>n</VAR> bytes (<TT>-</TT>), more than <VAR>n</VAR> bytes (<TT>+</TT>), or
exactly <VAR>n</VAR> bytes in length. If this flag is directly followed by a `<TT>k</TT>'
(`<TT>K</TT>'), `<TT>m</TT>' (`<TT>M</TT>'), or `<TT>p</TT>' (`<TT>P</TT>') (e.g. `<TT>Lk-50</TT>')
the check is performed with kilobytes, megabytes, or blocks (of 512 bytes)
instead.
<P>

</P>
<DT><TT>^</TT>
<DD>negates all qualifiers following it
<P>

</P>
<DT><TT>-</TT>
<DD>toggles between making the qualifiers work on symbolic links (the
default) and the files they point to
<P>

</P>
<DT><TT>M</TT>
<DD>sets the <TT>MARK_DIRS</TT> option for the current pattern
<A NAME="IDX195"></A>
<P>

</P>
<DT><TT>T</TT>
<DD>appends a trailing qualifier mark to the filenames, analogous to the
<TT>LIST_TYPES</TT> option, for the current pattern (overrides <TT>M</TT>)
<P>

</P>
<DT><TT>N</TT>
<DD>sets the <TT>NULL_GLOB</TT> option for the current pattern
<A NAME="IDX196"></A>
<P>

</P>
<DT><TT>D</TT>
<DD>sets the <TT>GLOB_DOTS</TT> option for the current pattern
<A NAME="IDX197"></A>
<P>

</P>
<DT><TT>n</TT>
<DD>sets the <TT>NUMERIC_GLOB_SORT</TT> option for the current pattern
<A NAME="IDX198"></A>
<P>

</P>
<DT><TT>o</TT><VAR>c</VAR>
<DD>specifies how the names of the files should be sorted. If <VAR>c</VAR> is
<TT>n</TT> they are sorted by name (the default); if it is <TT>L</TT> they
are sorted depending on the size (length) of the files; if <TT>l</TT> 
they are sorted by the number of links; if <TT>a</TT>, <TT>m</TT>, or <TT>c</TT>
they are sorted by the time of the last access, modification, or
inode change respectively; if <TT>d</TT>, files in subdirectories appear before
those in the current directory at each level of the search -- this is best
combined with other criteria, for example `<TT>odon</TT>' to sort on names for
files within the same directory.  Note that <TT>a</TT>, <TT>m</TT>, and <TT>c</TT> compare
the age against the current time, hence the first name in the list is the
youngest file. Also note that the modifiers <TT>^</TT> and <TT>-</TT> are used,
so `<TT>*(^-oL)</TT>' gives a list of all files sorted by file size in descending
order, following any symbolic links.
<P>

</P>
<DT><TT>O</TT><VAR>c</VAR>
<DD>like `<TT>o</TT>', but sorts in descending order; i.e. `<TT>*(^oc)</TT>' is the
same as `<TT>*(Oc)</TT>' and `<TT>*(^Oc)</TT>' is the same as `<TT>*(oc)</TT>'; `<TT>Od</TT>'
puts files in the current directory before those in subdirectories at each
level of the search.
<P>

</P>
<DT><TT>[</TT><VAR>beg</VAR>[<TT>,</TT><VAR>end</VAR>]<TT>]</TT>
<DD>specifies which of the matched filenames should be included in the
returned list. The syntax is the same as for array
subscripts. <VAR>beg</VAR> and the optional <VAR>end</VAR> may be mathematical
expressions. As in parameter subscripting they may be negative to make 
them count from the last match backward. E.g.: `<TT>*(-OL[1,3])</TT>'
gives a list of the names of the three largest files.
<P>

</DL>
<P>

More than one of these lists can be combined, separated by commas. The
whole list matches if at least one of the sublists matches (they are
`or'ed, the qualifiers in the sublists are `and'ed).  Some qualifiers,
however, affect all matches generated, independent of the sublist in
which they are given.  These are the qualifiers `<TT>M</TT>', `<TT>T</TT>',
`<TT>N</TT>', `<TT>D</TT>', `<TT>n</TT>', `<TT>o</TT>', `<TT>O</TT>' and the subscripts given
in brackets (`<TT>[...]</TT>').
</P>
<P>

If a `<TT>:</TT>' appears in a qualifier list, the remainder of the expression in
parenthesis is interpreted as a modifier (see <A HREF="zsh_13.html#SEC45">13.1.4 Modifiers</A>
in <A HREF="zsh_13.html#SEC41">13.1 History Expansion</A>).  Note that
each modifier must be introduced by a separate `<TT>:</TT>'.  Note also that the
result after modification does not have to be an existing file.  The
name of any existing file can be followed by a modifier of the form
`<TT>(:..)</TT>' even if no actual filename generation is performed.
Thus:
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>ls *(-/)
</pre></td></tr></table><P>

lists all directories and symbolic links that point to directories,
and
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>ls *(%W)
</pre></td></tr></table><P>

lists all world-writable device files in the current directory, and
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>ls *(W,X)
</pre></td></tr></table><P>

lists all files in the current directory that are
world-writable or world-executable, and
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>echo /tmp/foo*(u0^@:t)
</pre></td></tr></table><P>

outputs the basename of all root-owned files beginning with the string
`<TT>foo</TT>' in <TT>/tmp</TT>, ignoring symlinks, and
</P>
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>ls *.*~(lex|parse).[ch](^D^l1)
</pre></td></tr></table><P>

lists all files having a link count of one whose names contain a dot
(but not those starting with a dot, since <TT>GLOB_DOTS</TT> is explicitly
switched off) except for <TT>lex.c</TT>, <TT>lex.h</TT>, <TT>parse.c</TT> and <TT>parse.h</TT>.
<A NAME="Parameters"></A>
</P>
<P>

<HR SIZE="6">
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_13.html#SEC40"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_14.html#SEC63"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_24.html#SEC195">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<BR>
<FONT SIZE="-1">
This document was generated
by <I>Peter Stephenson</I> on <I>August, 9 2002</I>
using <A HREF="http://www.mathematik.uni-kl.de/~obachman/Texi2html
"><I>texi2html</I></A>
</FONT>

</BODY>
</HTML>