[תÔØ]linuxµÄtestÃüÁî
ÿһÖÖÌõ¼þÓï¾äµÄ»ù´¡¶¼ÊÇÅжÏʲôÊÇÕæʲôÊǼ١£ÊÇ·ñÁ˽âÆ乤×÷ÔÀí½«¾ö¶¨Äú±àдµÄÊÇÖÊÁ¿Ò»°ãµÄ½Å±¾»¹ÊÇÄú½«ÒýÒÔΪÈٵĽű¾¡£
Shell ½Å±¾µÄÄÜÁ¦Ê±³£±»µÍ¹À£¬µ«Êµ¼ÊÉÏÆäÄÜÁ¦µÄ·¢»ÓÊÜÖÆÓڽű¾×«Ð´ÕßµÄÄÜÁ¦¡£ÄúÁ˽âµÃÔ½¶à£¬Äú¾ÍÔ½ÄÜÏñ±äÏ··¨ËƵØ׫дһ¸öÎļþÀ´Ê¹ÈÎÎñ×Ô¶¯»¯ºÍ¼ò»¯ÄúµÄ¹ÜÀí¹¤×÷¡£
ÔÚ shell ½Å±¾ÖнøÐеÄÿһÖÖ²Ù×÷£¨³ý×î¼òµ¥µÄÃüÁî±à×éÖ®Í⣩¶¼ÐèÒª¼ì²éÌõ¼þ¡£ËùÓÐµÄ shell ½Å±¾“Âß¼” — ¹ãÒåÒâÒåϵēÂß¼” — ͨ³£¶¼¿ÉÒÔ·ÖΪÒÔÏÂÈý´óÀࣺ
if {condition exists} then ...
while {condition exists} do ...
until {condition exists} do ...
ÎÞÂÛËæºóµÄ²Ù×÷ÊÇʲô£¬ÕâЩ»ùÓÚÂß¼µÄÃüÁÒÀ¿¿ÅжÏÒ»ÖÖÌõ¼þÊÇ·ñÕæʵ´æÔÚÀ´¾ö¶¨ºóÐøµÄ²Ù×÷¡£test ÃüÁîÊÇʹµÃÔÚÿһÖÖÇé¿ö϶¼Äܹ»È·¶¨ÒªÅжϵÄÌõ¼þÊÇ·ñ´æÔÚµÄʵÓù¤¾ß¡£Òò´Ë£¬³¹µ×Á˽âÕâ¸öÃüÁî¶ÔÓÚ׫д³É¹¦µÄ shell ½Å±¾ÖÁ¹ØÖØÒª¡£
¹¤×÷ÔÀí
test ÃüÁî×î¶ÌµÄ¶¨Òå¿ÉÄÜÊÇÆÀ¹ÀÒ»¸ö±í´ïʽ£»Èç¹ûÌõ¼þΪÕ棬Ôò·µ»ØÒ»¸ö 0 Öµ¡£Èç¹û±í´ïʽ²»ÎªÕ棬Ôò·µ»ØÒ»¸ö´óÓÚ 0 µÄÖµ — Ò²¿ÉÒÔ½«Æä³ÆΪ¼ÙÖµ¡£¼ì²é×îºóËùÖ´ÐÐÃüÁîµÄ״̬µÄ×î¼ò±ã·½·¨ÊÇʹÓà $? Öµ¡£³öÓÚÑÝʾµÄÄ¿µÄ£¬±¾ÎÄÖеÄÀý×ÓÈ«²¿Ê¹ÓÃÁËÕâ¸ö²ÎÊý¡£
test ÃüÁîÆÚÍûÔÚÃüÁîÐÐÖÐÕÒµ½Ò»¸ö²ÎÊý£¬µ± shell ûÓÐΪ±äÁ¿¸³ÖµÊ±£¬Ôò½«¸Ã±äÁ¿ÊÓΪ¿Õ¡£ÕâÒâζ×ÅÔÚ´¦Àí½Å±¾Ê±£¬Ò»µ©½Å±¾Ñ°ÕҵIJÎÊý²»´æÔÚ£¬Ôò test ½«±¨¸æ¸Ã´íÎó¡£
µ±
ÊÔͼ±£»¤½Å±¾Ê±£¬Äú¿ÉÒÔͨ¹ý½«ËùÓвÎÊý°üº¬ÔÚË«ÒýºÅÖÐÀ´½â¾öÕâ¸öÎÊÌ⡣Ȼºó shell ½«±äÁ¿Õ¹¿ª£¬Èç¹û±äÁ¿Ã»ÓÐÖµ£¬ÄÇô½«´«µÝÒ»¸ö¿ÕÖµ¸ø
test¡£ÁíÒ»ÖÖ·½·¨ÊÇÔڽű¾ÄÚÔö¼ÓÒ»¸ö¶îÍâ¼ì²é¹ý³ÌÀ´ÅжÏÊÇ·ñÉèÖÃÁËÃüÁîÐвÎÊý¡£Èç¹ûûÓÐÉèÖÃÃüÁîÐвÎÊý£¬ÄÇô½Å±¾»á¸æËßÓû§È±ÉÙ²ÎÊý£¬È»ºóÍ˳ö¡£ÎÒÃÇ
»áͨ¹ýһЩÀý×ÓÀ´¸ü¾ßÌåµØ˵Ã÷ËùÓÐÕâЩÄÚÈÝ¡£
test ºÍ [ ÃüÁî
ËäÈ» Linux ºÍ UNIX µÄÿ¸ö°æ±¾Öж¼°üº¬ test ÃüÁµ«¸ÃÃüÁîÓÐÒ»¸ö¸ü³£ÓõıðÃû — ×ó·½À¨ºÅ£º[¡£test ¼°Æä±ðÃûͨ³£¶¼¿ÉÒÔÔÚ /usr/bin »ò /bin £¨È¡¾öÓÚ²Ù×÷ϵͳ°æ±¾ºÍ¹©Ó¦ÉÌ£©ÖÐÕÒµ½¡£
µ±ÄúʹÓÃ×ó·½À¨ºÅ¶ø·Ç test ʱ£¬Æäºó±ØÐëʼÖÕ¸ú×ÅÒ»¸ö¿Õ¸ñ¡¢ÒªÆÀ¹ÀµÄÌõ¼þ¡¢Ò»¸ö¿Õ¸ñºÍÓÒ·½À¨ºÅ¡£ÓÒ·½À¨ºÅ²»ÊÇÈκζ«Î÷µÄ±ðÃû£¬¶øÊDZíʾËùÐèÆÀ¹À²ÎÊýµÄ½áÊø¡£Ìõ¼þÁ½±ßµÄ¿Õ¸ñÊDZØÐèµÄ£¬Õâ±íʾҪµ÷Óà test£¬ÒÔÇø±ðÓÚͬÑù¾³£Ê¹Ó÷½À¨ºÅµÄ×Ö·û/ģʽƥÅä²Ù×÷¡£
test ºÍ [ µÄÓï·¨ÈçÏ£º
test expression
[ expression ]
ÔÚÕâÁ½ÖÖ
Ïà¹ØÎĵµ£º
Ò»£ºÇ°ÑÔ
×î½üÔÚÑо¿androidµÄsensor driver£¬Ö÷ÒªÊÇE-compass£¬ÆäÖÐÓõ½ÁËLinux input×Óϵͳ.ÔÚÍøÉÏÒ²¿´Á˺ܶàÕâ·½ÃæµÄ×ÊÁÏ£¬¸Ð¾õ»¹ÊÇÕâƪ·ÖÎöµÄ±È½ÏϸÖÂ͸³¹£¬Òò´ËתÔØÒ»ÏÂÒÔ±ã×Ô¼ºÑ§Ï°£¬Í¬Ê±ºÍ´ó¼Ò·ÖÏí£¡
£¨Õâƪ²©¿ÍÖ÷ÒªÊÇÒÔ¼üÅÌÇý¶¯ÎªÀýµÄ£¬²»¹ý½²½âµÄÊÇLinux Input Subsystem£¬¿ÉÒÔ×ÐϸµÄÑо¿Ò»Ï£¡£©
¼üÅÌÇý¶¯½«¼ì ......
дµÃÂùºÃµÄlinuxѧϰ±Ê¼Ç
linuxĿ¼¼Ü¹¹
/ ¸ùĿ¼
/bin ³£ÓõÄÃüÁî binary file µÄÄ¿錄
/boot ´æ·ÅϵͳÆô¶¯Ê±±ØÐë¶ÁÈ¡µÄµµ°¸£¬°üÀ¨ºËÐÄ (kernel) ÔÚÄÚ
/boot/grub/menu.lst GRUBÉèÖÃ
/boot/vmlinuz& ......
linux ¶¨Ê±ÈÎÎñ crontab Ïêϸ½âÊÍ
cron ÊÇlinuxµÄÄÚÖ÷þÎñ£¬µ«Ëü²»×Ô¶¯ÆðÀ´£¬¿ÉÒÔÓÃÒÔϵķ½·¨Æô¶¯¡¢¹Ø±ÕÕâ¸ö·þÎñ£º
ÒýÓÃ:
/sbin/service crond start //Æô¶¯·þÎñ
/sbin/service crond stop //¹Ø±Õ·þÎñ
/sbin/service crond restart //ÖØÆô·þÎñ
/sbin/service crond reload //Ö ......
1. ±ê×¼ÊäÈëµÄ¿ØÖÆ
Óï·¨£ºÃüÁî< Îļþ½«Îļþ×öΪÃüÁîµÄÊäÈë¡£
ÀýÈ磺
mail -s “mail test” das@163.com < file1 ½«Îļþfile1 µ±×öÐżþµÄÄÚÈÝ£¬Ö÷
ÌâÃû³ÆΪmail test£¬Ë͸øÊÕÐÅÈË¡£
2. ±ê×¼Êä³öµÄ¿ØÖÆ
Óï·¨£ºÃüÁî> Îļþ½«ÃüÁîµÄÖ´Ðнá¹ûËÍÖÁÖ¸¶¨µÄÎļþÖС£
ÀýÈç:
ls -l > list ½«Ö´ÐÐ&ldqu ......