diff options
Diffstat (limited to 'help/en/bash/select.html')
-rw-r--r-- | help/en/bash/select.html | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/help/en/bash/select.html b/help/en/bash/select.html new file mode 100644 index 0000000..d946185 --- /dev/null +++ b/help/en/bash/select.html @@ -0,0 +1,91 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> +<head> +<link rel="STYLESHEET" href="../term_tools/main.css" type="text/css"> +<title>select MAN Page</title> +<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> +</head><body><!-- #BeginLibraryItem "/Library/head_bash.lbi" --><div id="nav-menu"> +<ul> +<li><a class="rl" href="../term_tools/index.html"><img src="../term_tools/images/ss64.gif" title="Home" alt="Home"></a></li> +<li><a class="rl" href="../term_tools/bash"><img src="../term_tools/images/bash-l.gif" title="bash" alt="bash"></a></li> +<li><!-- Search Google --> +<form action="http://www.google.com/search" method="get" style="margin:0px;padding:0px;"> +<div align="right"> +<input name="q" type="text" class="body" size="25"> +<input class="submit" type="submit" value="Search"> +<input type="hidden" name="q" value="site:ss64.com/bash/"> +</div> +</form></li> +<li><a class="rr" href="syntax.html"><img src="../term_tools/images/syntax-r.gif" title="Bash Syntax"></a></li> +</ul> +</div> <!-- #EndLibraryItem --><h1> select</h1> +<p>The <code>select</code> construct allows the easy generation of + menus. It has almost the same syntax as the <code>for</code> command.</p> + +<pre>Syntax + select <var>name</var> [in <var>words</var> ...]; do <var>commands</var>; done</pre> +<p>The list of words following <code>in</code> is expanded, generating a list + of items. The set of expanded words is printed on the standard error output + stream, each preceded by a number.<br> + <br> + If the <samp>`in <var>words</var>'</samp> is omitted, the positional parameters + are printed, as if <samp>`in "$@"'</samp> had been specifed. The <code>PS3</code> + prompt is then displayed and a line is read from the standard input. If the + line consists of a number corresponding to one of the displayed words, then + the value of <var>name</var> is set to that word. If the line is empty, the + words and prompt are displayed again. If <code>EOF</code> is read, the <code>select</code> + command completes. Any other value read causes <var>name</var> to be set to + null. The line read is saved in the variable <code>REPLY</code>.<br> + <br> + The <var>commands</var> are executed after each selection until a <code>break</code> + or <code>return</code> command is executed, at which point the <code>select</code> + command completes. <br> + <br> + Here is an example that allows the user to pick a filename from the current + directory, and displays the name and index of the file selected. </p> +<pre>select fname in *; +do + echo you picked $fname \($REPLY\) + break; +done +</pre> +<p><code>((...))</code> </p> +<pre>(( <var>expression</var> )) +</pre> +<p> If the value of the expression is non-zero, the return status is 0; otherwise + the return status is 1. This is exactly equivalent to </p> +<pre>let "<var>expression</var>"</pre> +<p><em>The truly successful businessman is essentially a dissenter, a rebel who is seldom if ever satisfied with the <a href="http://www.statusquo.co.uk/">status quo</a>" - +J. Paul Getty</em></p> +<p><b>Related</b>:<a href="for.html"><br> + <br> + </a><a href="read.html">read</a> - read a line from standard input<a href="for.html"> + <br> + for</a> - Expand <var>words</var>, and execute <var>commands</var><br> + <a href="if.html">if</a> - Conditionally perform a command<br> + <a href="until.html">until</a> - Execute commands (until error)<br> +Equivalent Windows command: +<a href="../term_tools/nt/choice.html">CHOICE</a> - Accept keyboard input to a batch file</p> +<!-- #BeginLibraryItem "/Library/foot_bash.lbi" --><p align="left"><script type="text/javascript"><!-- +google_ad_client = "pub-6140977852749469"; +google_ad_width = 300; +google_ad_height = 250; +google_ad_format = "300x250_as"; +google_ad_type = "text_image"; +google_ad_channel ="1984328893"; +google_color_border = "CCCCCC"; +google_color_bg = "CCCCCC"; +google_color_link = "000000"; +google_color_text = "333333"; +google_color_url = "0000FF"; +//--></script> +<script type="text/javascript" + src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> +</script><br> +</p> +<div align="center"><hr size="1"> + <p id="top"><a href="#"><img src="../term_tools/images/top-4.gif" width="47" height="53" border="0" alt="Back to the Top" title="Back to the Top"></a></p> + <p class="tagline">© Copyright <a href="http://ss64.com/">SS64.com</a> 1999-2010<br> +Some rights reserved<br> +</p> +</div><!-- #EndLibraryItem --></body> +</html> |