藍森林首頁 | 返回主頁 | 本站地圖 | 站內搜索 | 聯繫信箱 |
 您目前的位置:首頁 > 自由軟件 > 技術交流 > 應用編程


    

藍森林 http://www.lslnet.com 2006年6月26日 11:18


請教關於shell中if的用法和變量的比較

如題
#!/bin/sh
echo start
kkk="0 0 0"
cnt=`ps -ef|grep ProgramName|grep -v grep |wc``
while true
do
  
  
  if  [ cnt=kkk ] ;then
  break
  fi
  
  sleep 1
  
  cnt=`ps -ef|grep ProgramName|grep -v grep |wc`
done

我在調試if時總是出現問題,無法比較兩個變量,請問該如何解決

請教關於shell中if的用法和變量的比較

[ $cnt=$kkk  ]

請教關於shell中if的用法和變量的比較

cnt是變量,kkk也是,要用$
所以應該是if [ $cnt = $kkk ]
注意空格的用法。



Copyright © 1999-2000 LSLNET.COM. All rights reserved. 藍森林網站 版權所有。 E-mail : webmaster@lslnet.com