mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-08 23:14:06 +08:00
19 lines
1.1 KiB
HTML
19 lines
1.1 KiB
HTML
<h1 id="let">let</h1>
|
||
<p>简单的计算器</p>
|
||
<h2 id="补充说明">补充说明</h2>
|
||
<p><strong>let命令</strong> 是bash中用于计算的工具,提供常用运算符还提供了方幂<code>**</code>运算符。在变量的房屋计算中不需要加上<code>$</code>来表示变量,如果表达式的值是非0,那么返回的状态值是0;否则,返回的状态值是1。</p>
|
||
<h3 id="语法">语法</h3>
|
||
<pre><code class="language-bash">let arg [arg ...] #arg代表运算式</code></pre>
|
||
<h3 id="用法">用法</h3>
|
||
<p>自加操作<code>let no++</code><br />
|
||
自减操作<code>let no--</code><br />
|
||
简写形式<code>let no+=10</code>,<code>let no-=20</code>,分别等同于<code>let no=no+10,``let no=no-20</code></p>
|
||
<h3 id="实例">实例</h3>
|
||
<pre><code class="language-bash">#!/bin/bash
|
||
let a=5+4 b=9-3
|
||
echo $a $b</code></pre>
|
||
<pre><code class="language-bash">#!/bin/bash
|
||
let "t1 = ((a = 5 + 3, b = 7 - 1, c = 15 - 4))"
|
||
echo "t1 = $t1, a = $a, b = $b"</code></pre>
|
||
<!-- Linux命令行搜索引擎:https://jaywcjlove.github.io/linux-command/ -->
|