LinuxÖÐÌØÊâ×Ö·ûµÄ½â¶ÁÓëÓ¦ÓÃ
LinuxÖÐÌØÊâ×Ö·ûµÄ½â¶ÁÓëÓ¦ÓÃ
ÔÚLinuxϵͳÖУ¬ÌØÊâ×Ö·ûÊÇÒ»ÖÖºÜÊÇÖ÷ÒªµÄ²¿·Ö£¬ËüÃÇÔÚÏÂÁîÐвÙ×÷ºÍ¾ç±¾±àдÖÐÆð×ÅÖÁ¹ØÖ÷ÒªµÄ×÷Óá£ÌØÊâ×Ö·ûͨ³£ÓÃÓÚ¿ØÖÆÏÂÁîµÄÐÐΪ¡¢Îļþ²Ù×÷¡¢¹ÜµÀÅþÁ¬µÈ·½Ãæ¡£ÏàʶÕâЩÌØÊâ×Ö·ûµÄ¼ÄÒåºÍÓ÷¨£¬Äܹ»Ìá¸ßÊÂÇéЧÂʺͱàд¾ç±¾µÄÄÜÁ¦¡£±¾ÎĽ«ÏÈÈÝһЩ³£¼ûµÄÌØÊâ×Ö·û¼°ÆäÓ÷¨£¬Í¬Ê±¸ø³öÏêϸµÄ´úÂëʾÀý¡£
ͨÅä·û
ͨÅä·ûÊÇÓÃÀ´Æ¥Åä¶à¸ö×Ö·ûµÄÌØÊâ×Ö·û£¬³£ÓõÄͨÅä·ûÓÐ*¡¢?¡¢[]µÈ¡£
*£ºÆ¥ÅäÁã¸ö»ò¶à¸öí§Òâ×Ö·û£»
?£ºÆ¥Åäµ¥¸öí§Òâ×Ö·û£»
[]£ºÆ¥ÅäÖ¸¶¨¹æÄ£ÄÚµÄ×Ö·û¡£
ʾÀý£º
# ²éÕÒÒÔtest¿ªÍ·µÄÎļþ ls test* # ²éÕÒ°üÀ¨"file"µÄÎļþ ls *file* # ɾ³ýtest¿ªÍ·µÄËùÓÐÎļþ rm test*
µÇ¼ºó¸´ÖÆ
Öض¨Ïò·ûºÅ
Öض¨Ïò·ûºÅÓÃÓÚ½«ÏÂÁîµÄÊä³öÖض¨Ïòµ½Ö¸¶¨Î»Ö㬳£¼ûµÄÖض¨Ïò·ûºÅÓÐ>¡¢>>ºÍ<¡£
>£º½«ÏÂÁîµÄÊä³öÖض¨Ïòµ½Îļþ£¬»áÁýÕÖÎļþÔÓÐÄÚÈÝ£»
>>£º½«ÏÂÁîµÄÊä³ö×·¼Óµ½Îļþĩβ£»
<£º´ÓÎļþÖжÁÈ¡ÊäÈë¡£
ʾÀý£º
# ½«lsÏÂÁîµÄÊä³öÖض¨Ïòµ½Îļþlist.txt ls > list.txt # ½«echoÏÂÁîµÄÊä³ö×·¼Óµ½Îļþmessage.txt echo "Hello, World!" >> message.txt # ´Óinput.txtÎļþÖжÁÈ¡ÊäÈë cat < input.txt
µÇ¼ºó¸´ÖÆ
¹ÜµÀ·ûºÅ
¹ÜµÀ·ûºÅ|ÓÃÓÚÅþÁ¬Á½¸öÏÂÁ½«µÚÒ»¸öÏÂÁîµÄÊä³ö×÷ΪµÚ¶þ¸öÏÂÁîµÄÊäÈ롣ͨ¹ý¹ÜµÀ·ûºÅ£¬¿ÉÒÔ½«¶à¸öÏÂÁî´®ÁªÆðÀ´£¬ÊµÏÖÖØ´óµÄ²Ù×÷¡£
ʾÀý£º
# ͳ¼ÆÄ¿½ñĿ¼ÏÂÎļþÊýÄ¿ ls | wc -l # ²éÕÒ°üÀ¨"error"µÄÈÕÖ¾Îļþ£¬²¢Êä³öµ½error.log grep "error" *.log | tee error.log
µÇ¼ºó¸´ÖÆ
תÒå·ûºÅ
תÒå·ûºÅ“ÓÃÓÚ×÷·ÏÌØÊâ×Ö·ûµÄÌØÊâ¼ÄÒ壬ʹÌØÊâ×Ö·û±äΪͨË××Ö·û¡£ÈôÊÇÐèÒªÔÚÏÂÁîÖÐʹÓÃÌØÊâ×Ö·û×Ô¼º£¬¿ÉÒÔͨ¹ýתÒå·ûºÅ¾ÙÐÐתÒå¡£
ʾÀý£º
# ½¨ÉèÃûΪ`file*`µÄÎļþ touch file* # ²éÕÒº¬ÓÐ*×Ö·ûµÄÎļþ ls *
µÇ¼ºó¸´ÖÆ
ÌØÊâ±äÁ¿
ÔÚLinux shell¾ç±¾ÖУ¬ÉÐÓÐһЩÌØÊâµÄ±äÁ¿ÓÃÓÚ»ñÈ¡ÌØÊâÐÅÏ¢£¬ÀýÈç$?ÓÃÓÚ»ñÈ¡ÉÏÒ»¸öÏÂÁîµÄÍ˳ö״̬¡¢$$ÓÃÓÚ»ñÈ¡Ä¿½ñÀú³ÌµÄPIDµÈ¡£
ʾÀý£º
# ´òÓ¡ÉÏÒ»¸öÏÂÁîµÄÍ˳ö״̬ echo $? # ´òÓ¡Ä¿½ñÀú³ÌµÄPID echo $$
µÇ¼ºó¸´ÖÆ
×ܽ᣺ÕÆÎÕLinuxÖÐÌØÊâ×Ö·ûµÄ¼ÄÒåºÍÓ÷¨£¬¹ØÓÚÌá¸ßÊÂÇéЧÂʺͱàд¾ç±¾¾ßÓÐÖ÷ÒªÒâÒ塣ͨ¹ý±¾ÎĵÄÏÈÈݺÍʾÀý£¬ÐÅÍжÁÕß¿ÉÒÔ¸üºÃµØÃ÷È·ºÍÔËÓÃÌØÊâ×Ö·û£¬Ê©Õ¹LinuxϵͳµÄÇ¿Ê¢¹¦Ð§¡£
ÒÔÉϾÍÊÇLinuxÖÐÌØÊâ×Ö·ûµÄ½â¶ÁÓëÓ¦ÓõÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡