---Ash数学运算

1718阅读 0评论2010-09-29 bzhao
分类:LINUX

> -----Original Message-----
> From:  
> [mailto:] On Behalf Of Aizer 
> Danny-BDA023
> Sent: Monday, January 17, 2005 07:34
> To: BusyBox (E-mail)
> Subject: [BusyBox] BusyBox ash arithmetic operations
> 
> Hello,
> 
> I was trying to find out whether BusyBox supports simple arithmetic
> operations with variables.

Well, it depends on which shell you use, as BusyBox contains
four different shells. Ash supports it, and I think msh does too.
If you use ash, then you should enable CONFIG_ASH_MATH_SUPPORT
to get arithmetic support.

The syntax for the arithmetic expressions follow the standard 
posix shell (IEEE 1003.1) arithmetic syntax (i.e., the same as 
bash uses).

> E.g., something like:
> 
> wc1=`wc -l file1`
> wc2=`wc -l file2`
> 
> total=$wc1 + $wc2			?????

total=$(( $wc1 + $wc2 ))

> if [ $total > MAX_WC ]; then

if [ $total -gt MAX_WC ]; then

> 	echo "squeak"
> fi
> 
> If it does not support such operations, is there any "workaround"?
> 
> Thanks,
> /Danny

//Peter

上一篇:32bit linux 如何支持大于4G的内存?
下一篇:----Install Android Development Ubuntu