Tag: Seq Font calculates the specified interaction of the comment line nts file
Bash has built-in support for integer arithmetic, but it does not support floating-point arithmetic
The BC command is a calculator language that supports interactive execution of arbitrary precision, while the BC Command makes it easy to do floating-point operations , and of course integer arithmetic is no longer spoken
In the BC working environment, you can use the following calculation symbols:
+ Addition
-Subtraction
* Multiplication
/Division
^ Index
% remainder
Seq 10;seq 1 10;seq 1 1 10
Cat << seq >> 123
Where you can use scale to Specify the number of digits after the decimal point when doing a "divide calculation" or "Remainder calculation" (the default is 0, which is an integer)
1. Bash
Example 1:a=2;b=3 echo $ (($a + $b)) #结果为5
2, BC quit
Examples 2:a=2;b=3 BC <<< 2*3(or BC <<< $a * $b) #结果为6
Example 3: BC enters interactive mode calculation: You can also enter multiple calculations on one line, with commas ; Apart
Example 4: You can also calculate the results directly without interacting echo "(6+3) * * |BC echo 15/4 |bc echo" SCALE=2;15/4 "|BC echo" 3+4;5*2;5^2;18/4 "|BC Echo $a + $b |BC
Example 5:BC can pick up the file name after
Cat Calc.txt
20+89
56-17
34*45
BC Calc.txt
109
39
1530
Example 6: You can also use the here command
bc << HERE
> 30+56
> 30-14
> 30*5
Here
86
16
150
3, Awkawk in the processing of files, you can perform operations, which of course can also be used to calculate the awk ' begin{a= (3+2) *2;printa} ' awk ' begin{a= (3+2) * *;b= (5+8) *10/5;printA, b} ' awk ' Begin{a= (3+2) *2;b= (5+8) *10/5;print2a,3b}‘
8, linux-Digital calculation