shell±à³ÌµÄÒ»¸öÎÊÌâ
££!/bin/shif cp test test1
then echo¡°cp done¡±
else echo ¡°cp fail¡±
fi
cp ³É¹¦²»ÊÇ·µ»Ø0 Âð£¿
ΪʲôÕâ¸öif ºóÖ´ÐеÄÊÇ1£¿ bashÀïÃæ£º0ÎªÕæ [root@localhost shell]# cat ./test
#!/bin/bash
if cp ./1.txt ./3.txt ;then
echo "done"
else
echo "no"
fi
[root@localhost shell]# ./test
done
[root@localhost shell]# echo $?
0
Ôõô»áÊÇ1ÄØ [quote]ÔÌûÓÉ [i]kandyche[/i] ÓÚ 2007-6-12 16:03 ·¢±í [url=http://www.linuxeden.com/forum/redirect.php?goto=findpost&pid=577024&ptid=156799][img]http://www.linuxeden.com/forum/images/common/back.gif[/img][/url]
££!/bin/sh
if cp test test1
then echo¡°cp done¡±
else echo ¡°cp fail¡±
fi
cp ³É¹¦²»ÊÇ·µ»Ø0 Âð£¿
ΪʲôÕâ¸öif ºóÖ´ÐеÄÊÇ1£¿ [/quote]
`[color=red]Õâ¸ö if ºóÖ´ÐеÄÊÇ 1[/color]' ÔõôÀí½â? ËûµÄÒâ˼¹À¼ÆÊÇ:cp test test2Ö´Ðзµ»ØµÄÊÇ1°É?
ÀÏÊǾõÕâÑùд¹Ö¹ÖµÄ,ÕâÑùд,Èç¹ûÖ´ÐÐʧ°Ü,·µ»ØµÄÊÇÒ»´®¶«Î÷°É,Èç¹ûÄãÒªÅжÏËüÖ´ÐÐÊÇ·ñÕý³£,ÕâÑùдºÃÁË:
cp test tet1
if [ $? -eq 0 ];then
echo ""
else
echo ""
fi
Ò³:
[1]