2018-05-17 10:28:44 1434瀏覽
在目前IT技術(shù)行業(yè)中,比如Linux開(kāi)發(fā)技術(shù)有趣的命令可以在Linux系統(tǒng)下做數(shù)學(xué)運(yùn)算:expr、factor、jot和bc命令。那么,可以在這些Linux命令行下做數(shù)學(xué)運(yùn)算嗎?當(dāng)然可以!事實(shí)上,有不少命令可以輕松完成這些操作,下面我們一起來(lái)看一下吧。
$count=0 $count=`expr$count+1` $echo$count 1
$expr11+123 134 $expr134/11 12 $expr134-11 123 $expr11*123 expr:syntaxerror<==oops! $expr11\*123 1353 $expr20%3 2
participants=11 total=156 share=`expr$total/$participants` remaining=`expr$total-$participants\*$share` echo$share 14 echo$remaining 2
$expr11=11 1 $expr11=12 0
$age=11 $expr$age=11 1
$expr"11"="11" 1 $expr"eleven"="11" 0
$expr10\>5 1 $expr10\>99 0
#!/bin/bash echo-n"Costtous>" readcost echo-n"Pricewe'reasking>" readprice if[`expr$price\>$cost`];then echo"Wemakemoney" else echo"Don'tsellit" fi
$./checkPrice Costtous>11.50 Pricewe'reasking>6 Wemakemoney
#!/bin/bash echo-n"Costtous>" readcost echo-n"Pricewe'reasking>" readprice if[`expr$price\>$cost`==1];then echo"Wemakemoney" else echo"Don'tsellit" fi factor
$factor111 111:337 $factor134 134:267 $factor17894 17894:223389 $factor1987 1987:1987
$jot810 10 11 12 13 14 15 16 17
$jot8102 10 9 8 7 5 4 3 2
$foriin`jot717`;doechoApril$i;done April17 April18 April19 April20 April21 April22 April23
$echo"123.4+5/6-(7.89*1.234)"|bc 113.664
$echo"sqrt(256)"|bc 16 $echo"s(90)"|bc-l .89399666360055789051
$echo"scale=5;4*a(1)"|bc-l 3.14156 $echo"scale=10;4*a(1)"|bc-l 3.1415926532 $echo"scale=20;4*a(1)"|bc-l 3.14159265358979323844 $echo"scale=40;4*a(1)"|bc-l 3.1415926535897932384626433832795028841968
$bc bc1.06.95 Copyright1991-1994,1997,1998,2000,2004,2006FreeSoftwareFoundation,Inc. ThisisfreesoftwarewithABSOLUTELYNOWARRANTY. Fordetailstype`warranty'. scale=2 3/4 .75 2/3 .66 quit
$bc bc1.06.95 Copyright1991-1994,1997,1998,2000,2004,2006FreeSoftwareFoundation,Inc. ThisisfreesoftwarewithABSOLUTELYNOWARRANTY. Fordetailstype`warranty'. obase=16 16<===entered 10<===response 256<===entered 100<===response quit
$echo"ibase=16;F2"|bc 242 $echo"obase=16;242"|bc F2
$((e=11)) $((e=e+7)) $echo$e 18 $((e--)) $echo$e 17 $((e=e**2)) $echo$e 289
$((x=11));((y=7)) $if((x>y));then >echo"x>y" >fi x>y $((x=11));((y=7));((z=3)) $if((x>y))>>((y>z));then >echo"lettersrolldownhill" >fi lettersrolldownhill
$if[x>y]<<[y>z];thenecho"lettersrolldownhill";fi lettersrolldownhill
$echo"2^3" 2^3 $echo"2^3"|bc 8
以上就是關(guān)于扣丁學(xué)堂Linux培訓(xùn)之Linux命令行下的數(shù)學(xué)運(yùn)算的詳細(xì)介紹,在讀完本文之后, 要了解更多關(guān)于Linux發(fā)展前景趨勢(shì),請(qǐng)關(guān)注扣丁學(xué)堂Linux培訓(xùn)官網(wǎng)、微信等平臺(tái),扣丁學(xué)堂IT職業(yè)在線學(xué)習(xí)教育平臺(tái)為您提供權(quán)威的Linux視頻教程系統(tǒng),通過(guò)千鋒扣丁學(xué)堂金牌講師在線錄制的Linux視頻教程課程,讓你快速掌握Linux從入門(mén)到精通開(kāi)發(fā)實(shí)戰(zhàn)技能??鄱W(xué)堂Linux技術(shù)交流群:422345477。
【關(guān)注微信公眾號(hào)獲取更多的學(xué)習(xí)資料】
查看更多關(guān)于“Linux培訓(xùn)資訊”的相關(guān)文章>>