您的位置:首页 > 其它

test

2016-03-07 22:29 204 查看
<!DOCTYPE html>

<html><head>

<meta http-equiv="Content-Type" content="text/html; charset=unicode">

<!--defaultCSS-->

<title>_1_1bash变量_交互_逻辑.md</title>

<style type="text/css" id="wiz_todo_style_id" wiz_link_version="01.00.09">.wiz-todo, .wiz-todo-img {width: 16px; height: 16px; cursor: default; padding: 0 10px 0 2px; vertical-align: -10%;-webkit-user-select: none;} .wiz-todo-label { display: inline-block; padding-top: 7px; padding-bottom: 6px; line-height: 1.5;} .wiz-todo-label-checked { color: #666;} .wiz-todo-label-unchecked {text-decoration: initial;} .wiz-todo-completed-info {padding-left: 44px; display: inline-block; } .wiz-todo-avatar { width:20px; height: 20px; vertical-align: -20%; margin-right:10px; border-radius: 2px;} .wiz-todo-account, .wiz-todo-dt { color: #666; }</style>

<style id="wiz_custom_css"> html, body { font-size: 15px; } body { font-family: Helvetica, 'Hiragino Sans GB', '微软雅黑', 'Microsoft YaHei UI', SimSun, SimHei, arial, sans-serif; line-height: 1.6; margin: 0; padding: 20px 36px; padding: 1.33rem 2.4rem; } h1, h2, h3, h4, h5, h6 { margin: 20px 0 10px; margin: 1.33rem 0 0.667rem; padding: 0; font-weight: bold; } h1 { font-size: 21px; font-size: 1.4rem; } h2 { font-size: 20px; font-size: 1.33rem; } h3 { font-size: 18px; font-size: 1.2rem; } h4 { font-size: 17px; font-size: 1.13rem; } h5 { font-size: 15px; font-size: 1rem; } h6 { font-size: 15px; font-size: 1rem; color: #777777; margin: 1rem 0; } div, p, ul, ol, dl, li { margin: 0; } blockquote, table, pre, code { margin: 8px 0; } ul, ol { padding-left: 32px; padding-left: 2.13rem; } blockquote { padding: 0 12px; padding: 0 0.8rem; } blockquote > :first-child { margin-top: 0; } blockquote > :last-child { margin-bottom: 0; } img { border: 0; max-width: 100%; height: auto !important; margin: 2px 0; } table { border-collapse: collapse; border: 1px solid #bbbbbb; } td { padding: 4px 8px; border-collapse: collapse; border: 1px solid #bbbbbb; } @media screen and (max-width: 660px) { body { padding: 20px 18px; padding: 1.33rem 1.2rem; } } @media only screen and (-webkit-max-device-width: 1024px), only screen and (-o-max-device-width: 1024px), only screen and (max-device-width: 1024px), only screen and (-webkit-min-device-pixel-ratio: 3), only screen and (-o-min-device-pixel-ratio: 3), only screen and (min-device-pixel-ratio: 3) { html, body { font-size: 17px; } body { line-height: 1.7; padding: 0.75rem 0.9375rem; color: #353c47; } h1 { font-size: 2.125rem; } h2 { font-size: 1.875rem; } h3 { font-size: 1.625rem; } h4 { font-size: 1.375rem; } h5 { font-size: 1.125rem; } h6 { color: inherit; } ul, ol { padding-left: 2.5rem; } blockquote { padding: 0 0.9375rem; } }</style><style name="wiz_tmp_editor_style">html, body { font-size: 15px;}body { font-family: Helvetica, 'Hiragino Sans GB', 微软雅黑, 'Microsoft YaHei UI', SimSun, SimHei, arial, sans-serif; line-height: 1.6; color: ; background-color: ; margin: 0; padding: 16px 20px;}h1, h2, h3, h4, h5, h6 { margin: 20px 0 10px; margin: 1.33rem 0 0.667rem; padding: 0; font-weight: bold;}h1 { font-size: 21px; font-size: 1.4rem;}h2 { font-size: 20px; font-size: 1.33rem;}h3 { font-size: 18px; font-size: 1.2rem;}h4 { font-size: 17px; font-size: 1.13rem;}h5 { font-size: 15px; font-size: 1rem;}h6 { font-size: 15px; font-size: 1rem; color: #777777; margin: 1rem 0;}div, p, ul, ol, dl, li { margin: 0;}blockquote, table, pre, code{ margin: 8px 0;}ul, ol { padding-left: 32px; padding-left: 2.13rem;}blockquote { border-left: 4px solid #dddddd; padding: 0 12px; padding: 0 0.8rem;}blockquote > :first-child { margin-top: 0;}blockquote > :last-child { margin-bottom: 0;}img { border: 0; max-width: 100%; height: auto !important; margin: 2px 0;}table { border-collapse: collapse; border: 1px solid #bbbbbb;}td { padding:4px 8px; border-collapse: collapse; border: 1px solid #bbbbbb;}@media screen and (max-width: 660px) { body { padding: 20px 18px; padding: 1.33rem 1.2rem; }}@media only screen and (-webkit-max-device-width: 1024px), only screen and (-o-max-device-width: 1024px), only screen and (max-device-width: 1024px), only screen and (-webkit-min-device-pixel-ratio: 3), only screen and (-o-min-device-pixel-ratio: 3), only screen and (min-device-pixel-ratio: 3) { html, body { font-size: 17px; } body { line-height: 1.7; padding: 0.75rem 0.9375rem; color: #353c47; } h1 { font-size: 2.125rem; } h2 { font-size: 1.875rem; } h3 { font-size: 1.625rem; } h4 { font-size: 1.375rem; } h5 { font-size: 1.125rem; } h6 { color: inherit; } ul, ol { padding-left: 2.5rem; } blockquote { padding: 0 0.9375rem; }}</style><link rel="stylesheet" type="text/css" href="file:///F:\Program Files (x86)\WizNote\WizTools\htmleditor\editor.css" wiz_style="unsave" charset="utf-8"><link rel="stylesheet" type="text/css" href="file:///F:\Program Files (x86)\WizNote\WizTools\htmleditor\scrollbar.css" wiz_style="unsave" charset="utf-8"><script type="text/javascript" src="file:///F:\Program Files (x86)\WizNote\WizTools\htmleditor\utils.js" wiz_style="unsave" charset="utf-8"></script><script type="text/javascript" src="file:///F:\Program Files (x86)\WizNote\WizTools\htmleditor\localize.js" wiz_style="unsave" charset="utf-8"></script><script type="text/javascript" src="file:///F:\Program Files (x86)\WizNote\WizTools\htmleditor\core\wizEditor.js" wiz_style="unsave" charset="utf-8"></script><script type="text/javascript" src="file:///F:\Program Files (x86)\WizNote\WizTools\htmleditor\core\checklist\todo.js" wiz_style="unsave" charset="utf-8"></script><script type="text/javascript" src="file:///F:\Program Files (x86)\WizNote\WizTools\htmleditor\core\imageresize\dragresize.js" wiz_style="unsave" charset="utf-8"></script><script type="text/javascript" src="file:///F:\Program Files (x86)\WizNote\WizTools\htmleditor\editorHelper.js" wiz_style="unsave" charset="utf-8"></script></head>

<body style="" contenteditable="true"><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;">##变量</div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;"><span style="font-size: 15px; line-height: 1.6;">变量可以由字母数字下划线组成,数字不打头。</span></div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;"><span style="font-size: 15px; line-height: 1.6;">bash为弱类型语言,</span><span style="line-height: 1.6;">变量</span><span style="line-height: 1.6;">默认类型是字符串型。如果要进行数值运算,则需要指定类型。</span></div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;">变量需要=连接,=左右没有空格,若变量的值有空格用引号。括起来。</div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;">变量可以叠加`echo $aa  aa="$aa"456 ` aa后再添456也可以`aa=${aa}456`</div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;"><span style="font-size: 15px; line-height: 1.6;">环境变量的名称建议写大写。</span></div><div style="background-color: rgb(255, 255, 255);"><font face="微软雅黑">变量引用` ${name}, $name`</font></div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;"><span style="font-size: 15px; line-height: 1.6;">###bash变量的类型</span></div><div style="background-color: rgb(255, 255, 255);"><font face="微软雅黑">本地变量:作用域仅为当前shell进程,就是用户自定义shell;</font></div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;">环境变量:作用域为当前shell进程及其子进程,主要和操作系统环境相关的数据。</div><div style="background-color: rgb(255, 255, 255);"><font face="微软雅黑">局部变量:作用域仅为某代码片断(函数上下文);</font></div><div style="background-color: rgb(255, 255, 255);"><font face="微软雅黑"><br></font></div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;">位置参数变量:当执行脚本的shell进程传递的参数,向脚本中传递参数或数据,变量名不能自定义,作用是固定的;</div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;">预定义变量:bash中已经定义好的变量,变量名不能自定义,变量作用固定。</div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;"><span style="font-size: 15px; line-height: 1.6;">位参变量是预定义的一种。从上到下越来越严格。</span></div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;"><span style="font-size: 15px; line-height: 1.6;">***</span></div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;"><span style="font-size: 15px; line-height: 1.6;"><br></span></div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;">####本地变量</div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;">本地变量:</div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;">set      //查看所有变量  unset删除变量。</div><div style="background-color: rgb(255, 255, 255);"><font face="微软雅黑">unset name</font><span style="font-family: 微软雅黑; line-height: 1.6;">撤销变量 ,此处并不是引用。</span><br></div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;">***</div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;"><span style="font-size: 15px; line-height: 1.6;">####环境变量</span><span style="line-height: 1.6;"> </span></div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;"><span style="line-height: 1.6;">#####变量声明和赋值方法</span></div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;"><span style="line-height: 1.6;">```</span></div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;"><span style="line-height: 1.6;">1.export 变量名=变量值  //声明为全局变量。</span></div><div style="background-color: rgb(255, 255, 255);"><div><font face="微软雅黑">2.name=value</font></div><div><span style="font-family: 微软雅黑; line-height: 1.6;">    </span><font face="微软雅黑">export name</font></div><div><font face="微软雅黑"><div>3. declare -x name=value</div><div>4. name=value</div><div>declare -x name</div></font></div></div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;"><span style="font-size: 15px; line-height: 1.6;">```</span></div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;"><span style="font-size: 15px; line-height: 1.6;">##### 引用(同上)</span></div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;"><span style="font-size: 15px; line-height: 1.6;"> ${na        me}</span></div><div style="background-color: rgb(255, 255, 255);"><div><font face="微软雅黑">查看环境变量:`export, declare -x, printenv, env`</font></div><div><font face="微软雅黑">撤销环境变量:`unset name`</font></div></div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;"><span style="font-size: 15px; line-height: 1.6;">在当前shell和子shell中生效,写入配置文件中对所有shell生效。</span></div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;"><span style="font-size: 15px; line-height: 1.6;">父shell的环境下,新建shell为子shell。直接输xxshell</span></div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;"><span style="line-height: 1.6;">   ` </span><span style="font-size: 15px; line-height: 1.6;">pstree                        //确定shell位置`   </span></div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;"><span style="line-height: 1.6;">    `</span>env  变量名              //查询环境变量`</div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;"><span style="line-height: 1.6;">   ` </span>unset  变量名          //删除变`</div><div style="background-color: rgb(255, 255, 255);"><div><font face="微软雅黑">注意:bash内嵌了许多环境变量(通常为全大写字符),用于定义bash的工作环境</font>:<span style="font-family: 微软雅黑; line-height: 1.6;">PATH, HISTFILE, HISTSIZE, HISTFILESIZE, HISTCONTROL, SHELL, HOME, UID, PWD, OLDPWD</span></div></div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;">PATH:用冒号分割的路径,系统命令所在。</div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;"><span style="background-color: inherit; line-height: 1.5; font-size: 15px;">自己的脚本不要拷到系统目录下,应该PATH="$PATH":/root  追加       </span></div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;">PS1;,系统定义提示符的变量,就是shell提示符,虽然不是环境变量,</div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;">***</div><div style="background-color: rgb(255, 255, 255);"><div><font face="微软雅黑">####只读变量</font></div><div><font face="微软雅黑">(1) declare -r name</font></div><div><font face="微软雅黑">(2) readonly name</font></div></div><div style="background-color: rgb(255, 255, 255);"><font face="微软雅黑">只读变量无法重新赋值,并且不支持撤销;存活时间为当前shell进程的生命周期,随shell进程终止而终止;</font></div><div style="background-color: rgb(255, 255, 255);">***</div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;">###bash算术运算</div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;"><span style="line-height: 1.6;">注:(因为bash中默认类型为字符型,需要自行设定才可运算)</span></div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;">算术运算符:`+  - * /  % **`<span style="line-height: 1.6;"><br></span></div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;"><span style="line-height: 1.6;">```</span><br></div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;"><span style="line-height: 1.6;"> declare [+或-] [选项] 变量名</span><br></div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;"><div> <span style="line-height: 1.6;">   </span><span style="line-height: 1.6;">-</span><span style="line-height: 1.6;">给变量设定类型属性  +取消变量的类型属性 </span></div><div><span style="line-height: 1.6;">    </span><span style="line-height: 1.6;">-i  将变量声明为整型   </span></div><div>    -x   将变量声明为环境变量  </div><div><span style="line-height: 1.6;">    </span><span style="line-height: 1.6;">-p 显示指定变量被声明的类型</span></div><div>  declare  -i cc=$aa+$bb  <br></div><div>```</div><div>####算术运算的方式:<span style="line-height: 22px;">  </span></div><div><span style="line-height: 22px;">支持一般运算符,逻辑运算符</span></div><div>1.  `<span style="line-height: 1.6;">let VAR=$num1 or $num2`  bash内建命令,通常用于运算</span><span style="line-height: 1.6;">  </span></div><div><span style="background-color: inherit; line-height: 1.5;">2.  `VAR=</span><span style="line-height: 1.6;">$[</span><span style="line-height: 1.6;">experssion</span><span style="line-height: 1.6;">]` </span><span style="line-height: 1.6; color: rgb(255, 0, 0);">(最常用)</span></div><div><span style="line-height: 22px;">3. `VAR=</span><span style="line-height: 1.6;">$((</span><span style="line-height: 1.6;">experssion</span><span style="line-height: 1.6;">))` </span></div><div><span style="line-height: 1.6;">4. </span><span style="line-height: 1.6;">`VAR=$(expr a + b  )`   //此处的表达式需要空格分割</span><span style="line-height: 1.6;"> </span></div><div><span style="line-height: 1.6;">例: </span></div><div><span style="line-height: 1.6;"> ` ff=$(($aa+$bb))`  //其中的空格有没有都行 ,</span><span style="background-color: inherit; line-height: 1.5;"> 单括号括起来的是系统命令  </span><span style="background-color: inherit; line-height: 1.5;">                 </span></div></div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;"><span style="line-height: 22px;"> `dd=$(expr $aa + $bb)`   //把括号里的命令结果赋dd</span><br></div><div style="background-color: rgb(255, 255, 255);"><div><font face="微软雅黑">注意:有些时候乘法符号需要转义;</font><span style="font-family: 微软雅黑; white-space: pre; line-height: 1.6;"> </span></div><div><font face="微软雅黑">####增强型赋值:</font></div><div><font face="微软雅黑">变量做某种算术运算后回存至此变量中;</font></div><div><font face="微软雅黑">```</font></div><div><font face="微软雅黑">`let i=$i+#`  </font><span class="Apple-tab-span" style="font-family: 微软雅黑; line-height: 1.6; white-space: pre;"> </span>`<span style="font-family: 微软雅黑; line-height: 1.6;">let i+=#`</span></div><div><font face="微软雅黑">`+=,-=,*=, /=, %=`</font><span style="font-family: 微软雅黑; white-space: pre; line-height: 1.6;"> </span></div><div><font face="微软雅黑">自增:`</font><font face="微软雅黑" style="line-height: 1.6;">VAR=$[$VAR+1]` ;`</font><span style="line-height: 1.6; font-family: 微软雅黑;">let  VAR+=1   `;`</span><span style="line-height: 1.6; font-family: 微软雅黑;">let  VAR++`</span></div><div><font face="微软雅黑">自减:`</font><span style="font-family: 微软雅黑; line-height: 1.6;">VAR=$[$VAR-1]`; `  </span><span style="font-family: 微软雅黑; line-height: 1.6;">let  VAR-=1`;`</span><span style="font-family: 微软雅黑; line-height: 1.6;">let  VAR--`</span></div></div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;">```</div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;">***</div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;">####条件测试</div><div style="background-color: rgb(255, 255, 255);"><div><font face="微软雅黑">条件测试:</font><span style="line-height: 1.6;">    </span><span style="font-family: 微软雅黑; line-height: 1.6;">判断某需求是否满足,需要由测试机制来实现;</span></div><div><span style="font-family: 微软雅黑; line-height: 1.6;">如何编写测试表达式以实现所需的测试:</span><br></div><div><span style="font-family: 微软雅黑; line-height: 1.6;">    </span><font face="微软雅黑">(1) 执行命令,并利用命令状态返回值来判断;</font></div><div><font face="微软雅黑"><span class="Apple-tab-span" style="white-space:pre"> </span>0:成功 </font><span class="Apple-tab-span" style="font-family: 微软雅黑; line-height: 1.6; white-space: pre;"> </span><span style="font-family: 微软雅黑; line-height: 1.6;">1-255:失败</span></div><div><span style="font-family: 微软雅黑; line-height: 1.6;">    </span><font face="微软雅黑">(2) 测试表达式</font></div><div><font face="微软雅黑"><span class="Apple-tab-span" style="white-space:pre"> </span>test  EXPRESSION;</font><span class="Apple-tab-span" style="font-family: 微软雅黑; line-height: 1.6; white-space: pre;"> </span><span style="font-family: 微软雅黑; line-height: 1.6;">[ EXPRESSION ];</span><span class="Apple-tab-span" style="font-family: 微软雅黑; line-height: 1.6; white-space: pre;"> </span><span style="font-family: 微软雅黑; line-height: 1.6;">[[ EXPRESSION ]];</span></div><div><span style="font-family: 微软雅黑; line-height: 1.6;">注意:EXPRESSION两端必须有空白字符,否则为语法错误;</span><span style="font-family: 微软雅黑; line-height: 1.6;">上述命令并不会主动输出结果,需要输入`echo$?`来查看上一次判断结果.</span><br></div><div><span class="Apple-tab-span" style="line-height: 1.6; white-space: pre;"><font face="微软雅黑">*** </font></span><br></div><div><font face="微软雅黑">#####bash的测试类型:</font></div><div><font face="微软雅黑">数值测试;</font><span style="font-family: 微软雅黑; line-height: 1.6;">字符串测试;</span><span style="font-family: 微软雅黑; line-height: 1.6;">文件测试</span></div><div><font face="微软雅黑">数值测试</font></div><div><font face="微软雅黑">```</font></div><div><span style="font-family: 微软雅黑; line-height: 1.6;"><div><span style="line-height: 1.6;">    </span>-eq:是否等于; [ $num1 -eq $num2 ]</div></span><span style="font-family: 微软雅黑; line-height: 1.6;"><div><span style="line-height: 1.6;">    -</span>ne:是否不等于;</div></span><span style="font-family: 微软雅黑; line-height: 1.6;"><div><span style="line-height: 1.6;">    </span>-gt:是否大于;</div></span><span style="font-family: 微软雅黑; line-height: 1.6;"><div><span style="line-height: 1.6;">    </span>-ge:是否大于等于;</div></span><span style="font-family: 微软雅黑; line-height: 1.6;"><div><span style="line-height: 1.6;">    </span>-lt:是否小于;</div></span><span style="font-family: 微软雅黑; line-height: 1.6;"><div><span style="line-height: 1.6;">    </span>-le:是否小于等于;</div></span></div><div><span style="font-family: 微软雅黑; line-height: 1.6;">```</span></div><div><span style="font-family: 微软雅黑; line-height: 1.6;"><br></span></div><div><span style="font-family: 微软雅黑; line-height: 1.6;"><div>字符串测试:</div><div>字符,变量比较的时候需要加引用;要使用[[]]  否则会出现不可预期的情况。</div><div>```</div></span><span style="font-family: 微软雅黑; line-height: 1.6;"><div><span style="line-height: 1.6;">    </span>==:是否等于;</div></span><span style="font-family: 微软雅黑; line-height: 1.6;"><div><span style="line-height: 1.6;">    </span>>:是否大于;</div></span><span style="font-family: 微软雅黑; line-height: 1.6;"><div><span style="line-height: 1.6;">    </span><:是否小于;</div></span><span style="font-family: 微软雅黑; line-height: 1.6;"><div><span style="line-height: 1.6;">    </span>!=:是否不等于;</div></span><span style="font-family: 微软雅黑; line-height: 1.6;"><div><span style="line-height: 1.6;">    </span>=~:左侧字符串是否能够被右侧的PATTERN所匹配;</div><div><span class="Apple-tab-span" style="white-space:pre"> </span></div></span><span style="font-family: 微软雅黑; line-height: 1.6;"><div><span style="line-height: 1.6;">    </span>-z "STRING":判断指定的字串是否为空;空则为真,不空则假;</div></span><div style="font-family: 微软雅黑; line-height: 1.6;"><span style="line-height: 1.6;">   </span><span style="line-height: 1.6;"> </span><span style="line-height: 1.6;">-n "STRING":判断指定的字符串是否不空;不空则真,空则为假;</span></div><div style="font-family: 微软雅黑; line-height: 1.6;"><span style="line-height: 1.6;">```</span></div><div style="font-family: 微软雅黑; line-height: 1.6;"><span style="line-height: 1.6;"><br></span></div><div style="font-family: 微软雅黑; line-height: 1.6;">文件测试</div><div style="font-family: 微软雅黑; line-height: 1.6;">```</div><div style="font-family: 微软雅黑; line-height: 1.6;"><div><span style="line-height: 1.6;">    </span>存在性测试</div><div><span style="line-height: 1.6;">    </span><span style="line-height: 1.6;">    </span><span style="line-height: 1.6;">-a  FILE</span></div><div><span style="line-height: 1.6;">    </span><span style="line-height: 1.6;">    </span><span style="line-height: 1.6;">-e  FILE  </span><span style="line-height: 1.6;">是否存在文件(是为真);</span></div><div>文件的存在性测试,存在则为真,否则则为假;</div><div>存在性及类型测试</div><div><span style="line-height: 1.6;">    </span>-b  FILE:是否存在并且为 块设备 文件;</div><div><span style="line-height: 1.6;">    </span>-c  FILE:是否存在并且为 字符设备 文件;</div><div><span style="line-height: 1.6;">    </span>-d  FILE:是否存在并且为 目录文件;</div><div><span style="line-height: 1.6;">    </span>-f  FILE:是否存在并且为 普通文件;</div><div><span style="line-height: 1.6;">    </span>-h  FILE或 -L  FILE:是否存在并且为 符号链接文件;</div><div><span style="line-height: 1.6;">    </span>-p FILE:是否存在且为 命名管道文件;</div><div><span style="line-height: 1.6;">    </span>-S  FILE:是否存在且为 套接字文件;</div><div>文件权限测试:</div><div><span style="line-height: 1.6;">    </span>-r  FILE:是否存在并且 对当前用户可读;</div><div><span style="line-height: 1.6;">    </span>-w  FILE:是否存在并且 对当前用户可写;</div><div><span style="line-height: 1.6;">    </span>-x  FILE:是否存在并且 对当前用户可执行;</div><div>特殊权限测试:</div><div><span style="line-height: 1.6;">    </span>-u  FILE:是否存在并且 拥有suid权限;用不多</div><div><span style="line-height: 1.6;">    </span>-g  FILE:是否存在并且 拥有sgid权限;<span style="line-height: 1.6;">用不多 </span></div><div><span style="line-height: 1.6;">    </span>-k  FILE:是否存在并且 拥有sticky权限;<span style="line-height: 1.6;">用不多</span></div><div>文件是否有内容:</div><div><span style="line-height: 1.6;">    </span>-s  FILE:是否有内容;</div><div>时间戳:</div><div><span style="line-height: 1.6;">    </span>-N FILE:文件自从上一次读操作后是否被修改过;</div><div>从属关系测试:</div><div><span style="line-height: 1.6;">    </span>-O  FILE:当前用户是否为文件的属主;</div><div><span style="line-height: 1.6;">    </span>-G  FILE:当前用户是否属于文件的属组;</div><div>双目测试:</div><div><span style="line-height: 1.6;">    </span>FILE1  -ef  FILE2:1与2是否指向同一个文件系统的相同inode的硬链接,<span style="line-height: 1.6;">inode号一致</span><span style="line-height: 1.6;">;</span></div><div><span style="line-height: 1.6;">    </span>FILE1  -nt  FILE2:FILE1是否新于FILE2;</div><div><span style="line-height: 1.6;">    </span>FILE1  -ot  FILE2:FILE1是否旧于FILE2;</div></div><div style="font-family: 微软雅黑; line-height: 1.6;">```</div><div style="font-family: 微软雅黑; line-height: 1.6;">***</div><div style="font-family: 微软雅黑; line-height: 1.6;"><div>####逻辑组合运算:</div><div>这样的执行也反映在CLI中。逻辑优先级非>与>或.</div><div>第一种方式:</div><div>```</div><div>COMMAND1 && COMMAND2<span style="line-height: 21.8125px;">    1对2才执行</span></div><div>COMMAND1 || COMMAND2    <span style="line-height: 21.8125px;">1不对2执行</span></div><div>! COMMAND </div><div><span style="line-height: 1.6;">[ -O FILE ] && [ -r FILE ]</span><br></div><div><span style="line-height: 21.8125px;">命令1;命令2    先后执行</span><br></div><div><span style="line-height: 21.8125px;">```</span></div><div><span style="line-height: 1.6;">第二种方式:</span><br></div><div>```</div><div>EXPRESSION1  -a  EXPRESSION2    <span style="line-height: 1.6;">逻辑与,判断1和判断2都成立,结果才为真</span></div><div>EXPRESSION1  -o  EXPRESSION2   <span style="line-height: 1.6;">逻辑或, 判断1和判断2有一个为真就是真</span></div><div>! EXPRESSION    <span style="line-height: 1.6;">逻辑非,原判断式取反</span></div><div><span style="line-height: 1.6;">[ -O FILE -a -x FILE ]</span><br></div></div><div style="font-family: 微软雅黑; line-height: 1.6;"><span style="line-height: 21.8125px;">命令1&& 命令2||命令3   1对执行2,1不对,执行3</span><br></div><div><div style="font-family: 微软雅黑; line-height: 21.81818199157715px; font-size: 15.454545021057129px;">```</div><div style="font-family: 微软雅黑; line-height: 21.81818199157715px; font-size: 15.454545021057129px;">***</div><div><div><span style="line-height: 21.8125px; font-family: 微软雅黑;">向脚本传递参数:</span><br></div><div><font face="微软雅黑"><span style="line-height: 21.8125px;">位置参数变量</span></font><span style="font-family: 微软雅黑; line-height: 1.6;">(只可以改动值,系统定义好的功能)</span></div><div><span style="line-height: 1.6; font-family: 微软雅黑;">```</span></div><div><span style="line-height: 1.6; font-family: 微软雅黑;">$n    n为数字,$0代表命令本身,$1-$9代表第一到九个参数,十以上的参数需要大括号包含如${}    </span><span style="line-height: 1.6; font-family: 微软雅黑;"> </span><br></div><div><span style="font-family: 微软雅黑; line-height: 1.6;">$1...接受脚本外传入的参数。</span></div><div><span style="line-height: 21.8125px; font-family: 微软雅黑;">轮替:`</span><span style="line-height: 21.8125px; font-family: 微软雅黑;">shift  
`:位置参数轮替;剔除前几个参数。</span></div></div><div style="font-family: 微软雅黑; line-height: 21.81818199157715px; font-size: 15.454545021057129px;"><div style="line-height: 24px;">```</div><div style="line-height: 24px;">特殊变量:</div><div style="line-height: 24px;">```</div><div style="line-height: 24px;">$*   所有参数,$*把所有参数看成一个整体,只会传入一次,一次全部传入。</div><div style="line-height: 24px;">$@ 所有参数,不过$@把每个参数区分对待,给几个传几次。</div><div style="line-height: 24px;">$#   所有参数的个数。 计算传入脚本的参数个数。            </div><div style="line-height: 24px;"> </div><div style="line-height: 24px;"><span style="font-size: 15.454545021057129px;">$$当前进程的PID</span></div><div style="line-height: 24px;">$!返回最后一个后台进程的PID</div><div style="line-height: 24px;"><span style="font-size: 15.454545021057129px; line-height: 21.81818199157715px;">```     </span></div></div><div style="font-family: 微软雅黑; line-height: 21.81818199157715px; font-size: 15.454545021057129px;">***        </div><div><font face="微软雅黑"><span style="line-height: 21.8125px;">#####脚本的状态返回值:</span></font></div><div><font face="微软雅黑"><span style="line-height: 21.8125px;">默认是脚本中执行的最后一条件命令的状态返回值;</span></font></div><div><span style="font-family: 微软雅黑; line-height: 1.6;">`$#` 最后一个命令的返回状态 (0-255) 返回0表示执行正确,命令找不到127,文件找不到2.(程序识别任意)</span></div><div><font face="微软雅黑"><span style="line-height: 21.8125px;">自定义状态退出状态码:</span></font></div><div><font face="微软雅黑"><span style="line-height: 21.8125px;">`exit  
:n`为自己指定的状态码;</span></font></div><div style="font-family: 微软雅黑; line-height: 21.81818199157715px; font-size: 15.454545021057129px;">注意:shell进程遇到exit时,即会终止,因此,整个脚本执行即为结束;             </div><div style="font-family: 微软雅黑; line-height: 21.81818199157715px; font-size: 15.454545021057129px;">***       </div></div></div></div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;">\d  显示日期,格式为“星期 月 日”</div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;">\h  显示简写主机名,如默认主机名“localhost”</div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;">\t   显示24小时制时间,格式 HH:MM:SS</div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;"><span style="font-size: 15px; line-height: 1.6;">\T  显示12小时制时间,格式同上</span></div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;">\A  显示24小时,格式为HH:MM</div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;"><span style="font-size: 15px; line-height: 1.6;">\u  显示当前用户</span></div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;">\w  显示当前所在目录的完整名称</div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;">\W 显示当前所在目录的最后一个目录。</div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;">\#   执行的第几个命令</div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;">\$   提示符如果是root会显示提示符为“#”,普通用户显示为“$” </div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;">         eg#PS1  显示当前提示符。自己改PS1=‘[]'</div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;"><br></div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;">              </div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;">###bash脚本编程之用户交互:</div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;">####read参数</div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;">```</div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;"><span style="font-size: 15px; line-height: 1.6;">read[选项][变量名]</span></div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;">  -p “PROMPT提示信息”: 在等待read输入时,输出提示信息        </div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;">  -t  TIMEOUT   :   read命令会一直等待用户输入,使用此选项可以指定等待时间</div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;">  -n  字符数:    read命令只接受指定的字符数,就会执行</div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;">  -s :               隐藏输入数据,适用于机密信息的输入        </div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;">```  </div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;">####<span style="font-family: Helvetica, 'Hiragino Sans GB', 微软雅黑, 'Microsoft YaHei UI', SimSun, SimHei, arial, sans-serif; line-height: 1.6;">echo用法</span></div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;"><div style="font-family: Helvetica, 'Hiragino Sans GB', 微软雅黑, 'Microsoft YaHei UI', SimSun, SimHei, arial, sans-serif;">```</div><div style="font-family: Helvetica, 'Hiragino Sans GB', 微软雅黑, 'Microsoft YaHei UI', SimSun, SimHei, arial, sans-serif;">echo [OPTION]...“ {转义符}[输出内容] ”</div><div style="font-family: Helvetica, 'Hiragino Sans GB', 微软雅黑, 'Microsoft YaHei UI', SimSun, SimHei, arial, sans-serif;">      -e  支持转义符</div><div style="font-family: Helvetica, 'Hiragino Sans GB', 微软雅黑, 'Microsoft YaHei UI', SimSun, SimHei, arial, sans-serif;"><span style="line-height: 1.6;">先添选项-e,在输出内容里添加转义符。</span></div><div style="font-family: Helvetica, 'Hiragino Sans GB', 微软雅黑, 'Microsoft YaHei UI', SimSun, SimHei, arial, sans-serif;"><span style="line-height: 1.6;">转义符</span><span style="line-height: 1.6;">    </span><span style="line-height: 1.6;">输出</span></div><div style="font-family: Helvetica, 'Hiragino Sans GB', 微软雅黑, 'Microsoft YaHei UI', SimSun, SimHei, arial, sans-serif;"><span style="line-height: 1.6;">\\</span><span style="line-height: 1.6;">       </span><span style="line-height: 1.6;">输出\本身</span><br></div><div style="font-family: Helvetica, 'Hiragino Sans GB', 微软雅黑, 'Microsoft YaHei UI', SimSun, SimHei, arial, sans-serif;">\a<span style="line-height: 1.6;">       </span><span style="line-height: 1.6;">输出警告音</span></div><div style="font-family: Helvetica, 'Hiragino Sans GB', 微软雅黑, 'Microsoft YaHei UI', SimSun, SimHei, arial, sans-serif;">\b <span style="line-height: 1.6;">      </span><span style="line-height: 1.6;">退格</span></div><div style="font-family: Helvetica, 'Hiragino Sans GB', 微软雅黑, 'Microsoft YaHei UI', SimSun, SimHei, arial, sans-serif;">\c<span style="line-height: 1.6;">      </span><span style="line-height: 1.6;">取消输出行末尾的转换符,和“-n”选项一样</span></div><div style="font-family: Helvetica, 'Hiragino Sans GB', 微软雅黑, 'Microsoft YaHei UI', SimSun, SimHei, arial, sans-serif;">\f<span style="line-height: 1.6;">      </span><span style="line-height: 1.6;">换页</span></div><div style="font-family: Helvetica, 'Hiragino Sans GB', 微软雅黑, 'Microsoft YaHei UI', SimSun, SimHei, arial, sans-serif;">\n<span style="line-height: 1.6;">        </span><span style="line-height: 1.6;">换行</span><br></div><div style="font-family: Helvetica, 'Hiragino Sans GB', 微软雅黑, 'Microsoft YaHei UI', SimSun, SimHei, arial, sans-serif;">\r<span style="line-height: 1.6;">      </span><span style="line-height: 1.6;">回车</span></div><div style="font-family: Helvetica, 'Hiragino Sans GB', 微软雅黑, 'Microsoft YaHei UI', SimSun, SimHei, arial, sans-serif;">\e      escape键<br>\t      水平制表符,<br>\v<span style="line-height: 1.6;">      </span><span style="line-height: 1.6;">垂直制表符</span><br></div><div style="font-family: Helvetica, 'Hiragino Sans GB', 微软雅黑, 'Microsoft YaHei UI', SimSun, SimHei, arial, sans-serif;">\0nnn<span style="line-height: 1.6;">    </span><span style="line-height: 1.6;">按照八进制ASCII表输出字符,0为数字0,nnn是三位八进制数</span><span style="line-height: 1.6;"><br></span></div><div style="font-family: Helvetica, 'Hiragino Sans GB', 微软雅黑, 'Microsoft YaHei UI', SimSun, SimHei, arial, sans-serif;"><span style="line-height: 1.6;">\xhh</span><span style="line-height: 1.6;">    </span><span style="line-height: 1.6;">按照十六进制ASCII表输出字符,其中hh是俩位十六进制数</span></div><div style="font-family: Helvetica, 'Hiragino Sans GB', 微软雅黑, 'Microsoft YaHei UI', SimSun, SimHei, arial, sans-serif;">```</div><div style="font-family: Helvetica, 'Hiragino Sans GB', 微软雅黑, 'Microsoft YaHei UI', SimSun, SimHei, arial, sans-serif;">echo默认结尾没有换行,print默认有换行符</div><div style="font-family: Helvetica, 'Hiragino Sans GB', 微软雅黑, 'Microsoft YaHei UI', SimSun, SimHei, arial, sans-serif;">***</div><div style="font-family: Helvetica, 'Hiragino Sans GB', 微软雅黑, 'Microsoft YaHei UI', SimSun, SimHei, arial, sans-serif;">#####echo的字符颜色</div><div style="font-family: Helvetica, 'Hiragino Sans GB', 微软雅黑, 'Microsoft YaHei UI', SimSun, SimHei, arial, sans-serif;"> `echo -e "\e[31m  abcd \e[0m" `   //输出红色字符abcd,31m表颜色,\e[31m起始     \e[0m"</div><div style="font-family: Helvetica, 'Hiragino Sans GB', 微软雅黑, 'Microsoft YaHei UI', SimSun, SimHei, arial, sans-serif;">支持颜色</div><div style="font-family: Helvetica, 'Hiragino Sans GB', 微软雅黑, 'Microsoft YaHei UI', SimSun, SimHei, arial, sans-serif;">30m=黑色   31m=红色   32m=绿色   33=***  34m=蓝色  35m=洋红色  36m=青色</div><div style="font-family: Helvetica, 'Hiragino Sans GB', 微软雅黑, 'Microsoft YaHei UI', SimSun, SimHei, arial, sans-serif;">37m=白色</div><div style="font-family: Helvetica, 'Hiragino Sans GB', 微软雅黑, 'Microsoft YaHei UI', SimSun, SimHei, arial, sans-serif;">***</div><div style="font-family: Helvetica, 'Hiragino Sans GB', 微软雅黑, 'Microsoft YaHei UI', SimSun, SimHei, arial, sans-serif;"><div style="font-family: 微软雅黑;">####printf </div><div style="font-family: 微软雅黑;">```</div><div style="font-family: 微软雅黑;">printf‘打印格式’ 实际内容    %s字符串  %f 浮点</div><div style="font-family: 微软雅黑;">      \a 警告声音输出      \b退格键(backspace)   \f  清屏      \n换行        \r enter键      </div><div style="font-family: 微软雅黑;">      \t  水平tab键(制表符,空格)            \v 垂直tab键                \xNN NN为两位数字按键 转数字为字符</div><div style="font-family: 微软雅黑;">不加‘’输出只认第一个格式输出符,后面也不能加文件名和管道。</div><div>```</div><div>***</div></div></div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;"><span style="background-color: inherit; line-height: 1.5;">        变量测试和替换</span></div><table border="1" cellpadding="2" cellspacing="0" style="font-size: inherit; margin-top: 10px; margin-bottom: 10px; background-color: rgb(255, 255, 255); font-family: 微软雅黑; width: 600px;"><tbody style="background-color: inherit;"><tr style="background-color: inherit;"><td valign="top" style="word-break: break-all; border-color: rgb(153, 153, 153); padding: 5px 16px 5px 12px; min-height: 25px; min-width: 25px; height: 25px; background-color: inherit; width: 129px;">变量置换方式</td><td valign="top" style="word-break: break-all; border-color: rgb(153, 153, 153); padding: 5px 16px 5px 12px; min-height: 25px; min-width: 25px; height: 25px; background-color: inherit; width: 129px;"><div style="min-width: 2px; background-color: inherit;">变量y没有设置</div></td><td valign="top" style="word-break: break-all; border-color: rgb(153, 153, 153); padding: 5px 16px 5px 12px; min-height: 25px; min-width: 25px; height: 25px; background-color: inherit; width: 129px;"><div style="min-width: 2px; background-color: inherit;">变量y为空值</div></td><td valign="top" style="word-break: break-all; border-color: rgb(153, 153, 153); padding: 5px 16px 5px 12px; min-height: 25px; min-width: 25px; height: 25px; background-color: inherit; width: 129px;"><div style="min-width: 2px; background-color: inherit;">变量y设置值</div></td></tr><tr style="background-color: inherit;"><td valign="top" style="word-break: break-all; border-color: rgb(153, 153, 153); padding: 5px 16px 5px 12px; min-height: 25px; min-width: 25px; height: 25px; background-color: inherit; width: 129px;">x=${y-新值}</td><td valign="top" style="word-break: break-all; border-color: rgb(153, 153, 153); padding: 5px 16px 5px 12px; min-height: 25px; min-width: 25px; height: 25px; background-color: inherit; width: 129px;"><div style="min-width: 2px; background-color: inherit;">x=新值</div></td><td valign="top" style="word-break: break-all; border-color: rgb(153, 153, 153); padding: 5px 16px 5px 12px; min-height: 25px; min-width: 25px; height: 25px; background-color: inherit; width: 129px;"><div style="min-width: 2px; background-color: inherit;">x为空</div></td><td valign="top" style="word-break: break-all; border-color: rgb(153, 153, 153); padding: 5px 16px 5px 12px; min-height: 25px; min-width: 25px; height: 25px; background-color: inherit; width: 129px;"><div style="min-width: 2px; background-color: inherit;">x=$y</div></td></tr><tr style="background-color: inherit;"><td valign="top" style="word-break: break-all; border-color: rgb(153, 153, 153); padding: 5px 16px 5px 12px; min-height: 25px; min-width: 25px; height: 25px; background-color: inherit; width: 129px;"><div style="min-width: 2px; background-color: inherit;">x=${y:-新值}</div></td><td valign="top" style="word-break: break-all; border-color: rgb(153, 153, 153); padding: 5px 16px 5px 12px; min-height: 25px; min-width: 25px; height: 25px; background-color: inherit; width: 129px;"><div style="min-width: 2px; background-color: inherit;">x=新值</div></td><td valign="top" style="word-break: break-all; border-color: rgb(153, 153, 153); padding: 5px 16px 5px 12px; min-height: 25px; min-width: 25px; height: 25px; background-color: inherit; width: 129px;"><div style="min-width: 2px; background-color: inherit;">x=新值</div></td><td valign="top" style="word-break: break-all; border-color: rgb(153, 153, 153); padding: 5px 16px 5px 12px; min-height: 25px; min-width: 25px; height: 25px; background-color: inherit; width: 129px;"><div style="min-width: 2px; background-color: inherit;">x=$y</div></td></tr><tr style="background-color: inherit;"><td valign="top" style="word-break: break-all; border-color: rgb(153, 153, 153); padding: 5px 16px 5px 12px; min-height: 25px; min-width: 25px; height: 33px; background-color: inherit; width: 129px;"><div style="min-width: 2px; background-color: inherit;">x=${y+新值}</div></td><td valign="top" style="word-break: break-all; border-color: rgb(153, 153, 153); padding: 5px 16px 5px 12px; min-height: 25px; min-width: 25px; height: 33px; background-color: inherit; width: 129px;"><div style="min-width: 2px; background-color: inherit;">x为空</div></td><td valign="top" style="word-break: break-all; border-color: rgb(153, 153, 153); padding: 5px 16px 5px 12px; min-height: 25px; min-width: 25px; height: 33px; background-color: inherit; width: 129px;">x=新值</td><td valign="top" style="word-break: break-all; border-color: rgb(153, 153, 153); padding: 5px 16px 5px 12px; min-height: 25px; min-width: 25px; height: 33px; background-color: inherit; width: 129px;"><div style="min-width: 2px; background-color: inherit;">x=新值</div></td></tr><tr style="background-color: inherit;"><td valign="top" style="word-break: break-all; border-color: rgb(153, 153, 153); padding: 5px 16px 5px 12px; min-height: 25px; min-width: 25px; height: 25px; background-color: inherit; width: 129px;"><div style="min-width: 2px; background-color: inherit;">x=${y:+新值}</div></td><td valign="top" style="word-break: break-all; border-color: rgb(153, 153, 153); padding: 5px 16px 5px 12px; min-height: 25px; min-width: 25px; height: 25px; background-color: inherit; width: 129px;"><div style="min-width: 2px; background-color: inherit;">x为空</div></td><td valign="top" style="word-break: break-all; border-color: rgb(153, 153, 153); padding: 5px 16px 5px 12px; min-height: 25px; min-width: 25px; height: 25px; background-color: inherit; width: 129px;"><div style="min-width: 2px; background-color: inherit;">x为空</div></td><td valign="top" style="word-break: break-all; border-color: rgb(153, 153, 153); padding: 5px 16px 5px 12px; min-height: 25px; min-width: 25px; height: 25px; background-color: inherit; width: 129px;"><div style="min-width: 2px; background-color: inherit;">x=新值</div></td></tr><tr style="background-color: inherit;"><td valign="top" style="word-break: break-all; border-color: rgb(153, 153, 153); padding: 5px 16px 5px 12px; min-height: 25px; min-width: 25px; height: 25px; background-color: inherit; width: 129px;"><div style="min-width: 2px; background-color: inherit;">x=${y=新值}</div></td><td valign="top" style="word-break: break-all; border-color: rgb(153, 153, 153); padding: 5px 16px 5px 12px; min-height: 25px; min-width: 25px; height: 25px; background-color: inherit; width: 129px;"><div style="min-width: 2px; background-color: inherit;">x=新值</div><div style="min-width: 2px; background-color: inherit;">y=新值</div></td><td valign="top" style="word-break: break-all; border-color: rgb(153, 153, 153); padding: 5px 16px 5px 12px; min-height: 25px; min-width: 25px; height: 25px; background-color: inherit; width: 129px;"><div style="min-width: 2px; background-color: inherit;">x为空</div><div style="min-width: 2px; background-color: inherit;">y值不变</div></td><td valign="top" style="word-break: break-all; border-color: rgb(153, 153, 153); padding: 5px 16px 5px 12px; min-height: 25px; min-width: 25px; height: 25px; background-color: inherit; width: 129px;"><div style="min-width: 2px; background-color: inherit;">x=$y</div><div style="min-width: 2px; background-color: inherit;">y值不变</div></td></tr><tr style="background-color: inherit;"><td valign="top" style="word-break: break-all; border-color: rgb(153, 153, 153); padding: 5px 16px 5px 12px; min-height: 25px; min-width: 25px; height: 25px; background-color: inherit; width: 129px;">x=${y:=新值}</td><td valign="top" style="word-break: break-all; border-color: rgb(153, 153, 153); padding: 5px 16px 5px 12px; min-height: 25px; min-width: 25px; height: 25px; background-color: inherit; width: 129px;"><div style="min-width: 2px; background-color: inherit;">x=新值</div><div style="min-width: 2px; background-color: inherit;">y=新值</div></td><td valign="top" style="word-break: break-all; border-color: rgb(153, 153, 153); padding: 5px 16px 5px 12px; min-height: 25px; min-width: 25px; height: 25px; background-color: inherit; width: 129px;"><div style="min-width: 2px; background-color: inherit;">x=新值</div><div style="min-width: 2px; background-color: inherit;">y=新值</div></td><td valign="top" style="word-break: break-all; border-color: rgb(153, 153, 153); padding: 5px 16px 5px 12px; min-height: 25px; min-width: 25px; height: 25px; background-color: inherit; width: 129px;">x=$y<br style="background-color: inherit;">y值不变<br style="background-color: inherit;"></td></tr><tr style="background-color: inherit;"><td valign="top" style="word-break: break-all; border-color: rgb(153, 153, 153); padding: 5px 16px 5px 12px; min-height: 25px; min-width: 25px; height: 28px; background-color: inherit; width: 129px;"><div style="min-width: 2px; background-color: inherit;">x=${y?新值}</div></td><td valign="top" style="word-break: break-all; border-color: rgb(153, 153, 153); padding: 5px 16px 5px 12px; min-height: 25px; min-width: 25px; height: 28px; background-color: inherit; width: 129px;"><div style="min-width: 2px; background-color: inherit;">新值输出到标准错误输出(就是屏幕)</div></td><td valign="top" style="word-break: break-all; border-color: rgb(153, 153, 153); padding: 5px 16px 5px 12px; min-height: 25px; min-width: 25px; height: 28px; background-color: inherit; width: 129px;"><div style="min-width: 2px; background-color: inherit;">x为空</div></td><td valign="top" style="word-break: break-all; border-color: rgb(153, 153, 153); padding: 5px 16px 5px 12px; min-height: 25px; min-width: 25px; height: 28px; background-color: inherit; width: 129px;"><div style="min-width: 2px; background-color: inherit;">x=$y</div></td></tr><tr style="background-color: inherit;"><td valign="top" style="word-break: break-all; border-color: rgb(153, 153, 153); padding: 5px 16px 5px 12px; min-height: 25px; min-width: 25px; height: 28px; background-color: inherit; width: 129px;"><div style="min-width: 2px; background-color: inherit;">x=${y:?新值}</div></td><td valign="top" style="word-break: break-all; border-color: rgb(153, 153, 153); padding: 5px 16px 5px 12px; min-height: 25px; min-width: 25px; height: 28px; background-color: inherit; width: 129px;"><div style="min-width: 2px; background-color: inherit;">新值输出到标准错误输出</div></td><td valign="top" style="word-break: break-all; border-color: rgb(153, 153, 153); padding: 5px 16px 5px 12px; min-height: 25px; min-width: 25px; height: 28px; background-color: inherit; width: 129px;">新值输出到标准错误输出</td><td valign="top" style="word-break: break-all; border-color: rgb(153, 153, 153); padding: 5px 16px 5px 12px; min-height: 25px; min-width: 25px; height: 28px; background-color: inherit; width: 129px;"><div style="min-width: 2px; background-color: inherit;">x=$y</div></td></tr></tbody></table><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;"><br style="background-color: inherit;"></div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;">注:程序使用,不需要记,多查。</div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;">测试方式中有没有:的区别就是在Y为空时候的对待方式。-+ 完全相反。=会影响xy  ?结果输出到屏幕。</div><div style="background-color: rgb(255, 255, 255);"><div><br></div></div><div style="background-color: rgb(255, 255, 255); font-family: 微软雅黑;"><br></div></body></html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: