ºìÁªLinuxÃÅ»§
Linux°ïÖú

ÖÕÓÚ½â¾öÁËÕâ¸öÎÊÌâ

·¢²¼Ê±¼ä:2009-08-14 21:59:02À´Ô´:ºìÁª×÷Õß:jagub
¼ÇµÃÇ°¼¸¸öÔÂÎÒÔÚÕâÀïÌá¹ýÒ»¸öÎÊÌ⣬ûÓÐÈ˻شð

ÎÊÌâÊÇÕâÑùµÄ
ÓÃtail¼àÊÓÈÕÖ¾Îļþ£¬ÒòΪÕâ¸öÈÕÖ¾µÄÄÚÈÝÌ«¶àҲ̫¸´ÔÓ£¬
ËùÒÔÖ»ÏëÔÚÅöµ½ SQL£Û Õâ¸ö´ÊµÄʱºò¿ªÊ¼Êä³öÈÕÖ¾
µ½³öÏÖ £Ý µÄʱºò½áÊøÊäÈë¡£
ÎÊÌâÊÇSQL[ ºÍ ] Ö®¼ä»áÓкܶ໻ÐУ¬
¶øÇÒÒª²»Í£¶ÙµØ¼àÊÓÎļþ

ÔÚÊÕµ½ÁË7Ô·ݵĽ±ÀøÊ顶LinuxÃüÁîÐкÍshell½Å±¾±à³Ì±¦µä¡·
ÒÔºó£¬È«ÃæµÄѧϰÁËshell£¬ÖÕÓڳɹ¦µØ½â¾öÁËÕâ¸öÎÊÌâ[code]#!/bin/bash
found=0
function filter {
while read line
if (($found == 1))
then
chk=`echo $line | grep -c ']'`
else
chk=`echo $line | grep -c 'SQL\['`
fi
if (($chk > 0))
then
if (($found == 1))
then
echo "]"
echo
fi
found=$[1 - $found]
fi
do
if (($found == 1))
then
echo $line
fi
done
}
tail -n 100 -f $1 | filter
[/code]Æ©Èç°ÑÉÏÊöµÄ½Å±¾±£´æΪtest.sh
È»ºóchmod +x test.sh
¾Í¿ÉÒÔÓÃ./test.sh ÈÕÖ¾ÎļþÃû
À´¼àÊÓÎļþÁË

Ì«¸ÐлºìÁªÁË
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 13 ÌõÆÀÂÛ

  1. zhoupingxiaaa ÓÚ 2010-05-22 23:38:43·¢±í:

    Ò»Æðѧϰ¿©

  2. sclzwj ÓÚ 2010-01-05 19:12:28·¢±í:

    ѧϰÁË¡£¡£¡£

  3. »¶ÀÖʱ¹â ÓÚ 2009-12-25 02:33:06·¢±í:

    ¹§Ï²°¡£¡

  4. hery_yang ÓÚ 2009-12-13 13:05:50·¢±í:

    ºÜÏÛĽ¥Ö÷ÓкÃÊé°¡£¬¿àÓÚºÃÊéȱ·¦

  5. dxplrct ÓÚ 2009-09-16 09:01:31·¢±í:

    kanbudong

  6. shenhao0129 ÓÚ 2009-09-15 22:03:15·¢±í:

    ºÇºÇ£¡¹§Ï²°¡£¡¿´À´ÎÒÒ²ÒªºÃºÃµÄѧϰÁË£¡¶¼ÂäºóºÜ¶¼¶àÁË

  7. jagub ÓÚ 2009-08-30 22:20:21·¢±í:

    Õâ¸öÎÊÌâÀ§ÈÅÁËÎÒ°ëÄêÖ®¾Ã¡£
    ¿´ÊéѧϰÁËÁ½Ìì¾Í¸ã¶¨ÁË¡£

    ÓÐÒ»±¾ºÃÊéµÄÈ·ÊDz»Ò»ÑùµÄ£¡

  8. cwqing1973 ÓÚ 2009-08-30 20:08:05·¢±í:

    ÃüÁî°üÀ¨µÄÄÚÈÝÊÇÌ«¶àÁË£¬¸÷ÖÖÃüÁî°üº¬Á˵çÄÔ¸÷¸ö·½ÃæµÄ֪ʶ£¬¡­¡­

  9. 35749810 ÓÚ 2009-08-29 19:08:50·¢±í:

    ¹§Ï²Â¥Ö÷

  10. yangshan ÓÚ 2009-08-16 17:14:38·¢±í:

    ºÃÌù ¸´ÖÆÒ»ÏÂÏ£¡:0wmjh(1

  11. l460618498 ÓÚ 2009-08-15 01:05:21·¢±í:

    ÎÒ¿ÉÒÔÁìÊéÂ𣿣¿

  12. rxotav ÓÚ 2009-08-15 00:06:32·¢±í:

    ¹§Ï²Â¥Ö÷

  13. wangyu ÓÚ 2009-08-14 23:36:23·¢±í:

    ÄãµÄÎÊÌâÌ«Óм¼ÊõÁË£¬Ò»°ãÈË´ð²»Á˹þ