28
Apr
shell面试题一个,对比小数大小
帮朋友写的,功能是监视top中的cpu使用,这题比较冷门的是shell中小数的对比。
#!/bin/bash
while :
do
top -d 30 -b -n 1 > /root/top1
top -d 60 -b -n 1 > /root/top2
BEFORE=`awk 'NR==3{print $2}' /root/top1 | sed -n 's/[^0-9.]//gp'`
AFTER=`awk 'NR==3{print $2}' /root/top2 | sed -n 's/[^0-9.]//gp'`
expr $BEFORE \> $AFTER &>/dev/null
if (( $? == 1 ))
then
echo $AFTER>/tmp/now
fi && break
done
exit 0 |
shell学了点,現在学ruby
[回复]
admin 回复:
05月 3rd, 2009 at 22:31
ruby不错,不过也推荐看看python
[回复]
ABitNo 回复:
05月 5th, 2009 at 12:43
那是,我什么都想看。。。不过就是没时间
主要是为了做网站而学ruby的。。。RoR。。。
[回复]