linux shell½Å±¾Ö®ifÅжÏ
ÎÞÂÛʲô±à³ÌÓïÑÔ¶¼Àë²»¿ªÌõ¼þÅжϡ£SHELLÒ²²»ÀýÍâ¡£
if list then
do something here
elif list then
do another thing here
else
do something else here
fi
EX1:
#!/bin/sh
SYSTEM=`uname -s` #»ñÈ¡²Ù×÷ϵͳÀàÐÍ£¬ÎÒ±¾µØÊÇlinux
if [ $SYSTEM = "Linux" ] ; then #Èç¹ûÊÇlinuxµÄ»°´òÓ¡linux×Ö·û´®
echo "Linux"
elif [ $SYSTEM = "FreeBSD" ] ; then
echo "FreeBSD"
elif [ $SYSTEM = "Solaris" ] ; then
echo "Solaris"
else
echo "What?"
fi #ifend
»ù±¾ÉÏºÍÆäËû½Å±¾ÓïÑÔÒ»Ñù¡£Ã»ÓÐÌ«´óÇø±ð¡£²»¹ýÖµµÃ×¢ÒâµÄÊÇ¡£[]ÀïÃæµÄÌõ¼þÅжϡ£
1 ×Ö·û´®ÅжÏ
str1 = str2¡¡¡¡¡¡¡¡¡¡¡¡µ±Á½¸ö´®ÓÐÏàͬÄÚÈÝ¡¢³¤¶ÈÊ±ÎªÕæ
str1 != str2¡¡¡¡¡¡¡¡¡¡ µ±´®str1ºÍstr2²»µÈÊ±ÎªÕæ
-n str1¡¡¡¡¡¡¡¡¡¡¡¡¡¡ µ±´®µÄ³¤¶È´óÓÚ0Ê±ÎªÕæ(´®·Ç¿Õ)
-z str1¡¡¡¡¡¡¡¡¡¡¡¡¡¡ µ±´®µÄ³¤¶ÈΪ0Ê±ÎªÕæ(¿Õ´®)
str1¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ µ±´®str1Ϊ·Ç¿ÕÊ±ÎªÕæ
2 Êý×ÖµÄÅжÏ
int1 -eq int2¡¡¡¡¡¡¡¡Á½ÊýÏàµÈÎªÕæ
int1 -ne int2¡¡¡¡¡¡¡¡Á½Êý²»µÈÎªÕæ
int1 -gt int2¡¡¡¡¡¡¡¡int1´óÓÚint2ÎªÕæ
int1 -ge int2¡¡¡¡¡¡¡¡int1´óÓÚµÈÓÚint2ÎªÕæ
int1 -lt int2¡¡¡¡¡¡¡¡int1СÓÚint2ÎªÕæ
int1 -le int2¡¡¡¡¡¡¡¡int1СÓÚµÈÓÚint2ÎªÕæ
3 ÎļþµÄÅжÏ
-r file¡¡¡¡¡¡¡¡¡¡Óû§¿É¶ÁÎªÕæ
-w file¡¡¡¡¡¡¡¡¡¡Óû§¿ÉÐ´ÎªÕæ
-x file¡¡¡¡¡¡¡¡¡¡Óû§¿ÉÖ´ÐÐÎªÕæ
-f file¡¡¡¡¡¡¡¡¡¡ÎļþΪÕý¹æÎļþÎªÕæ
-d file¡¡¡¡¡¡¡¡¡¡ÎļþÎªÄ¿Â¼ÎªÕæ
-c file¡¡¡¡¡¡¡¡¡¡ÎļþΪ×Ö·ûÌØÊâÎļþÎªÕæ
-b file¡¡¡¡¡¡¡¡¡¡ÎļþΪ¿éÌØÊâÎļþÎªÕæ
-s file¡¡¡¡¡¡¡¡¡¡Îļþ´óС·Ç0Ê±ÎªÕæ
-t file¡¡¡¡¡¡¡¡¡¡µ±ÎļþÃèÊö·û(ĬÈÏΪ1)Ö¸¶¨µÄÉ豸ΪÖÕ¶ËÊ±ÎªÕæ
3 ¸´ÔÓÂß¼ÅжÏ
-a ¡¡ ¡¡¡¡¡¡¡¡¡¡ Óë
-o¡¡¡¡¡¡¡¡¡¡¡¡¡¡ »ò
!¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡·Ç
ÓÐʱ¿´½Å±¾µÄʱºò²»ÖªµÀ¾ßÌåµÄÅжÏÊÇʲô£¬¿ÉÒԲο¼Ò»Ï¡£
Ïà¹ØÎĵµ£º
linuxÔÚ2.6°æ±¾ÒÔºó½«ÅäÖÃÎļþÓÉÔÀ´µÄconfig.in¸ÄΪkconfig£¬¶ÔÓÚkconfigµÄÓï·¨ÔÚ/Documentation/kbuild/kconfig-language.txtÖÐ×öÁËÏêϸµÄ˵Ã÷£¬ÔÚÕâÀï¸ø³ökconfig-language.txtµÄÖÐÎİ档
½éÉÜ
----
ÔÚÅäÖÃÊý¾Ý¿âµÄÅäÖÃÑ¡ÏîÊÇÒÔÊ÷µÄÐÎʽ×éÖ¯µÄ£º
+- Code maturity level options
| +- ......
1¡¢ÓÃGCC±àÒë
1.1¡¢´´½¨Ô´Îļþ
(main.c) C Ô´Îļþ - main.c
#include
#include “reciprocal.hpp”
int main (int argc, char **argv)
{
int i;
i = atoi (argv[1]);
printf (“The reciprocal of %d is %g\n”, i, reciprocal (i ......
ÀûÓÃ
ÏÂÔØµÄÕâ¶Î´úÂ룬³É¹¦ÊµÏÖÁËÊØ»¤½ø³Ì£¬ÔÀ´ÊØ»¤½ø³ÌÊǺܼòµ¥µÄÊÂÇé¡£
¡¡¡¡ÔÚmainº¯ÊýÖÐÖ´ÐÐ
¡¡¡¡init_daemon();//³õʼ»¯ÎªDaemon
¡¡¡¡¾Í¿ÉÒ԰ѽø³Ì±ä³ÉÊØ»¤½ø³Ì
¡¡¡¡
#include
#include
#include
#include
#include
void
init_daemon(void
)
{
int
pid;
int
i;
if
(pid=fork()) ......
ת×Ô£ºhttp://lkml.org/lkml/2005/8/2/242
--------------------------------------------------------------------------------------------
from
Jesper Juhl <>
Subject
Documentation - how to apply patches for various trees
Date
Tue, 2 Aug 2005 23:32:20 +0200
Hi,
How to apply the -rc, -git, ......
ÔÚÕýʽ½éÉÜ iptables
µÄʹÓÃ
֮ǰ£¬ÎÒÃÇÏÈÀ´¿´Ò»ÏÂºÍ iptables
Ïà¹ØµÄһЩ»ù±¾¸ÅÄî¡£ÎÒÃÇÏÂÃæ½«»áƵ·±Ê¹ÓÃ
µ½
ËüÃÇ¡£
Æ¥Å䣨match£©£º·ûºÏÖ¸¶¨µÄÌõ¼þ£¬±ÈÈçÖ¸¶¨µÄ IP µØÖ·ºÍ¶Ë¿Ú¡£
¶ªÆú£¨drop£©£ºµ±Ò»¸ö°üµ½´ïʱ£¬¼òµ¥µØ¶ªÆú£¬²»×öÆäËüÈκδ¦Àí¡£
½ÓÊÜ£¨accept£©£ººÍ¶ªÆúÏà·´£¬½ÓÊÜÕâ¸ö°ü£¬ÈÃÕâ¸ö°üͨ¹ý¡£
¾ ......