⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testsandcomparisons.html

📁 Shall高级编程
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><HTML><HEAD><TITLE>Tests and Comparisons: Alternatives</TITLE><METANAME="GENERATOR"CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+"><LINKREL="HOME"TITLE="Advanced Bash-Scripting Guide"HREF="index.html"><LINKREL="UP"TITLE="Miscellany"HREF="miscellany.html"><LINKREL="PREVIOUS"TITLE="Shell Wrappers"HREF="wrapper.html"><LINKREL="NEXT"TITLE="A script calling itself (recursion)"HREF="recursionsct.html"><METAHTTP-EQUIV="Content-Style-Type"CONTENT="text/css"><LINKREL="stylesheet"HREF="common/kde-common.css"TYPE="text/css"><METAHTTP-EQUIV="Content-Type"CONTENT="text/html; charset=iso-8859-1"><METAHTTP-EQUIV="Content-Language"CONTENT="en"><LINKREL="stylesheet"HREF="common/kde-localised.css"TYPE="text/css"TITLE="KDE-English"><LINKREL="stylesheet"HREF="common/kde-default.css"TYPE="text/css"TITLE="KDE-Default"></HEAD><BODYCLASS="SECT1"BGCOLOR="#FFFFFF"TEXT="#000000"LINK="#AA0000"VLINK="#AA0055"ALINK="#AA0000"STYLE="font-family: sans-serif;"><DIVCLASS="NAVHEADER"><TABLESUMMARY="Header navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><THCOLSPAN="3"ALIGN="center">Advanced Bash-Scripting Guide: An in-depth exploration of the art of shell scripting</TH></TR><TR><TDWIDTH="10%"ALIGN="left"VALIGN="bottom"><AHREF="wrapper.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom">Chapter 33. Miscellany</TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="recursionsct.html"ACCESSKEY="N">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><DIVCLASS="SECT1"><H1CLASS="SECT1"><ANAME="TESTSANDCOMPARISONS"></A>33.4. Tests and Comparisons: Alternatives</H1><P>For tests, the <AHREF="tests.html#DBLBRACKETS">[[    ]]</A>	  construct may be more appropriate than <TTCLASS="USERINPUT"><B>[	  ]</B></TT>. Likewise, arithmetic comparisons might benefit	  from the <AHREF="dblparens.html">((    ))</A> construct.	  <TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="100%"><TR><TD><PRECLASS="PROGRAMLISTING">   1&nbsp;a=8   2&nbsp;   3&nbsp;# All of the comparisons below are equivalent.   4&nbsp;test "$a" -lt 16 &#38;&#38; echo "yes, $a &#60; 16"         # "and list"   5&nbsp;/bin/test "$a" -lt 16 &#38;&#38; echo "yes, $a &#60; 16"    6&nbsp;[ "$a" -lt 16 ] &#38;&#38; echo "yes, $a &#60; 16"    7&nbsp;[[ $a -lt 16 ]] &#38;&#38; echo "yes, $a &#60; 16"          # Quoting variables within   8&nbsp;(( a &#60; 16 )) &#38;&#38; echo "yes, $a &#60; 16"             # [[ ]] and (( )) not necessary.   9&nbsp;  10&nbsp;city="New York"  11&nbsp;# Again, all of the comparisons below are equivalent.  12&nbsp;test "$city" \&#60; Paris &#38;&#38; echo "Yes, Paris is greater than $city"  13&nbsp;                                  # Greater ASCII order.  14&nbsp;/bin/test "$city" \&#60; Paris &#38;&#38; echo "Yes, Paris is greater than $city"   15&nbsp;[ "$city" \&#60; Paris ] &#38;&#38; echo "Yes, Paris is greater than $city"   16&nbsp;[[ $city &#60; Paris ]] &#38;&#38; echo "Yes, Paris is greater than $city"  17&nbsp;                                  # Need not quote $city.  18&nbsp;  19&nbsp;# Thank you, S.C.</PRE></TD></TR></TABLE></P></DIV><DIVCLASS="NAVFOOTER"><HRALIGN="LEFT"WIDTH="100%"><TABLESUMMARY="Footer navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top"><AHREF="wrapper.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="index.html"ACCESSKEY="H">Home</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top"><AHREF="recursionsct.html"ACCESSKEY="N">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">Shell Wrappers</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="miscellany.html"ACCESSKEY="U">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">A script calling itself (recursion)</TD></TR></TABLE></DIV></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -