Chinaunix首页 | 论坛 | 博客
  • 博客访问: 658000
  • 博文数量: 135
  • 博客积分: 5217
  • 博客等级: 大校
  • 技术积分: 1289
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-05 17:36
文章分类

全部博文(135)

文章存档

2016年(1)

2012年(5)

2011年(15)

2010年(63)

2009年(51)

分类: LINUX

2010-09-29 10:07:32

> -----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

阅读(1588) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~