linux¹ÜµÀÏÂÁîÔõô´ò
¹ÜµÀÏÂÁîÔÚ linux ÖÐͨ¹ý¹ÜµÀ·û£¨|£©½¨É裬ʹһ¸öÏÂÁîµÄÊä³ö³ÉΪÁíÒ»¸öÏÂÁîµÄÊäÈë¡£ÀýÈ磬ls | grep .txt ½«ÁгöÒÔ .txt ×îºóµÄÎļþ¡£¹ÜµÀÖеĶà¸öÏÂÁî¿É½«Êä³ö×÷ΪºóÐøÏÂÁîµÄÊäÈ룬ÀýÈ磬ls | grep .txt | wc -l ͳ¼ÆÒÔ .txt ×îºóµÄÎļþÊýÄ¿¡£¹ÜµÀ¿Éת´ïÑ¡ÏÈç ls -l | grep .txt ÒÔÊúÏßÍÑÀëÊä³ö¡£×¢ÖØ£¬¹ÜµÀ½öת´ï±ê×¼Êä³öµ½±ê×¼ÊäÈ룬ÐèÈ·±£¼æÈÝÐÔÒÔʵÏÖÏÂÁî×Ô¶¯»¯¡£
Linux ¹ÜµÀÏÂÁ
¹ÜµÀÏÂÁîÊÇÒ»ÖÖ½«Ò»¸öÏÂÁîµÄÊä³ö×÷ΪÁíÒ»¸öÏÂÁîµÄÊäÈëµÄ»úÖÆ¡£ÔÚ Linux ÖУ¬Ê¹ÓùܵÀ·û£¨|£©À´½¨Éè¹ÜµÀ¡£
½¨Éè¹ÜµÀ£º
Òª½¨Éè¹ÜµÀ£¬ÇëʹÓÃÒÔÏÂÓï·¨£º
command1 | command2
µÇ¼ºó¸´ÖÆ
ÀýÈ磬ÒÔÏÂÏÂÁ ls ÏÂÁîµÄÊä³ö×÷Ϊ grep ÏÂÁîµÄÊäÈ룺
ls | grep .txt
µÇ¼ºó¸´ÖÆ
Õ⽫ÁгöÄ¿½ñĿ¼ÖÐËùÓÐÒÔ .txt ×îºóµÄÎļþ¡£
¹ÜµÀÖеĶà¸öÏÂÁ
¿ÉÒÔͨ¹ý½«¶à¸öÏÂÁîÓùܵÀ·ûÅþÁ¬ÆðÀ´£¬ÔڹܵÀÖн¨Éè¶à¸öÏÂÁî¡£ÀýÈ磬ÒÔÏÂÏÂÁ ls ÏÂÁîµÄÊä³ö×÷Ϊ grep ÏÂÁîµÄÊäÈ룬²¢½« grep ÏÂÁîµÄÊä³ö×÷Ϊ wc ÏÂÁîµÄÊäÈ룺
ls | grep .txt | wc -l
µÇ¼ºó¸´ÖÆ
Õ⽫ͳ¼ÆÄ¿½ñĿ¼ÖÐÒÔ .txt ×îºóµÄÎļþµÄÊýÄ¿¡£
¹ÜµÀÖеÄÑ¡Ï
¿ÉÒÔÏò¹ÜµÀÖеÄÏÂÁîת´ïÑ¡Ïî¡£ÀýÈ磬ÒÔÏÂÏÂÁ ls ÏÂÁîµÄÊä³öÒÔÊúÏßÍÑÀëµÄÃûÌÃ×÷Ϊ grep ÏÂÁîµÄÊäÈ룺
ls -l | grep .txt
µÇ¼ºó¸´ÖÆ
×¢ÖØÊÂÏ
¹ÜµÀÖ»Äܽ«±ê×¼Êä³öת´ï¸ø±ê×¼ÊäÈë¡£
È·±£ÏÂÁîµÄÊä³öÓëÊäÈëÏÂÁîËùÐèµÄÊäÈëÀàÐͼæÈÝ¡£
¹ÜµÀÏÂÁîÊÇÒ»¸öÇ¿Ê¢µÄ¹¤¾ß£¬¿ÉÒÔÓÃÓÚÖ´ÐÐÖØ´óµÄʹÃü×Ô¶¯»¯¡£
ÒÔÉϾÍÊÇlinux¹ÜµÀÏÂÁîÔõô´òµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡