Unix shell mathematical computing commands

Source: Internet
Author: User

1.Use the value assignment statement:
Format:
LetValue assignment expression
【Tip] The Value assignment expression can be omitted as follows:((Value assignment expression))
Example: Give the independent variableIAdd1
Let I = I + 1
Or
(I = I + 1) ----------- High Efficiency
Or
#! /Bin/bash
Let "T1 = (A = 5 + 3, B = 7-1, C = 15-4 ))"
Echo "T1 = $ T1, A = $ A, B = $ B"

2.UseExprCommand:
Example: Give the independent variableIAdd1
I = 'expr $ I + 1' ----------- Low Efficiency

3.UseBCCommand:
BCYesUNIXIt can also be used under the command line:
Example: Give the independent variableIAdd1
I = 'echo $ I + 1 | bc' ----------- Low Efficiency
※BecauseBCSupports scientific computing, so this method is very powerful.

4. integer operations can also be directly calculated using integer variables
example:
typeset-I a = 1 B = 3
A = a + B ----------- High Efficiency
echo $ A
result is 4

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.