×ðÁú¿­Ê±¹ÙÍøµÇ¼

ÔõÑùͨ¹ýLinuxÏÂÁîÐй¤¾ß¾ÙÐÐÈÕÖ¾ÆÊÎöºÍÌáÈ¡£¿

ÔõÑùͨ¹ýlinuxÏÂÁîÐй¤¾ß¾ÙÐÐÈÕÖ¾ÆÊÎöºÍÌáÈ¡£¿

¸ÅÊö£º

ÈÕÖ¾ÊÇϵͳºÍÓ¦ÓóÌÐòÔËÐÐÀú³ÌÖб¬·¢µÄÖ÷ÒªÐÅÏ¢¼Í¼ £¬Í¨¹ý¶ÔÈÕÖ¾¾ÙÐÐÆÊÎöºÍÌáÈ¡ £¬¿ÉÒÔ×ÊÖúÎÒÃÇÅÅÅÌÎÊÌâ¡¢ÆÊÎöϵͳ״̬¡¢¼à¿ØÐÔÄܵÈ¡£ÔÚLinuxϵͳÖÐ £¬ÎÒÃÇ¿ÉÒÔʹÓÃÏÂÁîÐй¤¾ßÀ´´¦ÀíÈÕÖ¾ £¬±¾ÎĽ«ÏÈÈÝһЩ³£ÓõÄLinuxÏÂÁîÐй¤¾ßÒÔ¼°ÔõÑùʹÓÃËüÃǾÙÐÐÈÕÖ¾ÆÊÎöºÍÌáÈ¡¡£

grepÏÂÁ

grepÏÂÁîÊÇÒ»¸ö¹¦Ð§Ç¿Ê¢µÄÎı¾ËÑË÷¹¤¾ß £¬Ëü¿ÉÒÔÓÃÀ´ËÑË÷°üÀ¨Ö¸¶¨×Ö·û´®µÄÈÕÖ¾ÐÐ £¬²¢½«ÇкÏÌõ¼þµÄÐдòÓ¡³öÀ´¡£ÀýÈç £¬ÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÀ´²éÕÒ°üÀ¨Òªº¦×Ö”error”µÄÈÕÖ¾ÐУº

grep "error" logfile.log

µÇ¼ºó¸´ÖÆ

grepÏÂÁ֧³ÖÕýÔò±í´ïʽµÄʹÓà £¬¿ÉÒÔʵÏÖ¸üÎÞаµÄËÑË÷¡£ÀýÈç £¬ÒÔÏÂÏÂÁ²éÕÒ°üÀ¨ÒÔ”error”¿ªÍ·µÄÈÕÖ¾ÐУº

grep "^error" logfile.log

µÇ¼ºó¸´ÖÆ

awkÏÂÁ

awkÏÂÁîÊÇÒ»ÖÖÇ¿Ê¢µÄÎı¾´¦Àí¹¤¾ß £¬¿ÉÒÔƾָ֤¶¨µÄ×ֶξÙÐÐÈÕÖ¾ÌáÈ¡ºÍÆÊÎö¡£ÎÒÃÇ¿ÉÒÔʹÓÃawkÏÂÁîÀ´ÌáÈ¡ÈÕÖ¾ÖеÄÌض¨×ֶΠ£¬²¢¶Ô×ֶξÙÐд¦Àí¡£ÀýÈç £¬ÒÔÏÂÏÂÁÌáÈ¡³öÈÕÖ¾Öеĵڶþ¸ö×ֶΠ£¬²¢´òÓ¡³öÀ´£º

awk '{print $2}' logfile.log

µÇ¼ºó¸´ÖÆ

awkÏÂÁ֧³Ö×Ô½ç˵µÄÖ§½â·û £¬Ä¬ÈÏÖ§½â·ûÊÇ¿Õ¸ñ¡£ÀýÈç £¬ÈôÊÇÈÕÖ¾ÖеÄ×Ö¶ÎÊÇÒÔðºÅ”:”ÍÑÀëµÄ £¬ÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÀ´ÌáÈ¡µÚÒ»¸ö×ֶΣº

awk -F: '{print $1}' logfile.log

µÇ¼ºó¸´ÖÆ

sedÏÂÁ

sedÏÂÁîÊÇÒ»ÖÖÇ¿Ê¢µÄÎı¾Ìæ»»¹¤¾ß £¬¿ÉÒÔÓÃÓÚÈÕÖ¾µÄÐ޸ĺ͹ýÂË¡£ÀýÈç £¬ÒÔÏÂÏÂÁ°ÑÈÕÖ¾ÖеÄËùÓДerror”Ì滻Ϊ”warning”£º

sed 's/error/warning/g' logfile.log

µÇ¼ºó¸´ÖÆ

sedÏÂÁ֧³ÖÕýÔò±í´ïʽµÄʹÓà £¬¿ÉÒÔʵÏÖ¸üÖØ´óµÄÌæ»»ºÍ¹ýÂË¡£ÀýÈç £¬ÒÔÏÂÏÂÁɾ³ýËùÓеĿÕÐУº

sed '/^$/d' logfile.log

µÇ¼ºó¸´ÖÆ

sortÏÂÁ

sortÏÂÁî¿ÉÒÔÓÃÀ´¶ÔÈÕÖ¾¾ÙÐÐÅÅÐò¡£ÀýÈç £¬ÒÔÏÂÏÂÁƾ֤ÈÕÖ¾ÖеĵÚÈý¸ö×ֶξÙÐÐÉýÐòÅÅÐò£º

sort -k3n logfile.log

µÇ¼ºó¸´ÖÆ

sortÏÂÁ֧³Öƾ֤¶à¸ö×ֶξÙÐÐÅÅÐò £¬¿ÉÒÔƾ֤ÐèÒªÖ¸¶¨²î±ðµÄ×ֶκÍÅÅÐò·½·¨¡£

uniqÏÂÁ

uniqÏÂÁî¿ÉÒÔÓÃÍù¸´³ýÈÕÖ¾ÖеÄÖظ´ÐС£ÀýÈç £¬ÒÔÏÂÏÂÁȥ³ýÈÕÖ¾ÖÐÒ»Á¬·ºÆðµÄÖظ´ÐУº

uniq logfile.log

µÇ¼ºó¸´ÖÆ

uniqÏÂÁ֧³Ö¶ÔÖظ´ÐоÙÐмÆÊý £¬²¢Ö»ÏÔʾÖظ´ÐеÄÊýÄ¿¡£ÀýÈç £¬ÒÔÏÂÏÂÁͳ¼ÆÖظ´ÐеÄÊýÄ¿£º

uniq -c logfile.log

µÇ¼ºó¸´ÖÆ

ÒÔÉÏÊÇһЩ³£ÓõÄLinuxÏÂÁîÐй¤¾ß £¬ÔÚÏÖʵʹÓÃÖÐ £¬ÎÒÃÇ¿ÉÒÔƾ֤ÐèҪ͎áʹÓà £¬ÒÔµÖ´ï¿ìËÙ¡¢×¼È·µØÆÊÎöºÍÌáÈ¡ÈÕÖ¾µÄÄ¿µÄ¡£ÕÆÎÕÕâЩ¹¤¾ßµÄʹÓÃÒªÁì £¬¿ÉÒÔ×ÊÖúÎÒÃǸüºÃµØÆÊÎöºÍ´¦ÀíÈÕÖ¾ £¬Ìá¸ßϵͳºÍÓ¦ÓóÌÐòµÄÎȹÌÐÔºÍÐÔÄÜ¡£

×¢£ºÒÔÉÏÏÂÁîµÄʾÀý½ö¹©²Î¿¼ £¬ÏÖʵʹÓÃʱƾ֤ÏêϸÇéÐξÙÐе÷½â¡£

ÒÔÉϾÍÊÇÔõÑùͨ¹ýLinuxÏÂÁîÐй¤¾ß¾ÙÐÐÈÕÖ¾ÆÊÎöºÍÌáÈ¡£¿µÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±¹ÙÍøµÇ¼ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
ÍøÕ¾µØͼ