ÿ¸ö³ÌÐòÔ±¶¼Ó¦¸ÃÖªµÀµÄ8¸öLinuxÃüÁî
¡¡¡¡Ã¿¸ö³ÌÐòÔ±£¬ÔÚÖ°ÒµÉúÑĵÄij¸öʱ¿Ì£¬×ܻᷢÏÖ×Ô¼ºÐèÒªÖªµÀһЩLinux·½ÃæµÄ֪ʶ¡£ÎÒ²¢²»ÊÇ˵ÄãÓ¦¸Ã³ÉΪһ¸öLinuxר¼Ò£¬ÎÒµÄÒâ˼ÊÇ£¬µ±Ãæ¶ÔlinuxÃüÁîÐÐÈÎÎñʱ£¬ÄãÓ¦¸ÃÄܺÜÊìÁ·µÄÍê³É¡£ÊÂʵÉÏ£¬Ñ§»áÁËÏÂÃæ8¸öÃüÁÎÒ»ù±¾ÉÏÄÜÍê³ÉÈκÎÐèÒªÍê³ÉµÄÈÎÎñ¡£
¡¡¡¡×¢Ò⣺ÏÂÃæµÄÿ¸öÃüÁÓÐÊ®·Ö·á¸»µÄÎĵµËµÃ÷¡£ÕâƪÎÄÕ²¢²»ÊÇÀ´Ï꾡µÄչʾÿ¸öÃüÁîµÄ¸÷ÖÖ¹¦Óõġ£ÎÒÔÚÕâÀïÒª½²µÄÊÇÕ⼸¸ö×î³£ÓõÄÃüÁîµÄ×î³£¼ûÓ÷¨¡£Èç¹ûÄã¶ÔlinuxÃüÁî²¢²»ÊǺÜÁ˽⣬ÄãÏëÕÒһЩÕâ·½ÃæµÄ×ÊÁÏѧϰ£¬ÄÇÕâƪÎÄÕ½«»á¸øÄãÒ»¸ö»ù±¾µÄÖ¸µ¼¡£
¡¡¡¡ÈÃÎÒÃÇ´Ó´¦ÀíһЩÊý¾Ý¿ªÊ¼¡£¼ÙÉèÎÒÃÇÓÐÁ½¸öÎļþ£¬·Ö±ð¼Ç¼µÄ¶©µ¥Çåµ¥ºÍ¶©µ¥´¦Àí½á¹û¡£
order.out.log 8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99 8:23:45 112, 1, Joy of Clojure, Hardcover, 29.99 8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99 order.in.log 8:22:20 111, Order Complete 8:23:50 112, Order sent to fulfillment 8:24:20 113, Refund sent to processing
cat
cat ¨C Á¬½ÓÎļþ£¬²¢Êä³ö½á¹û
¡¡¡¡cat ÃüÁî·Ç³£µÄ¼òµ¥£¬Äã´ÓÏÂÃæµÄÀý×Ó¿ÉÒÔ¿´µ½¡£
jfields$ cat order.out.log 8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99 8:23:45 112, 1, Joy of Clojure, Hardcover, 29.99 8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99
¡¡¡¡¾ÍÏñËüµÄ˵Ã÷ÃèÊöµÄ£¬Äã¿ÉÒÔÓÃËüÀ´Á¬½Ó¶à¸öÎļþ¡£
jfields$ cat order.* 8:22:20 111, Order Complete 8:23:50 112, Order sent to fulfillment 8:24:20 113, Refund sent to processing 8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99 8:23:45 112, 1, Joy of Clojure, Hardcover, 29.99 8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99
¡¡¡¡Èç¹ûÄãÏë¿´ÕâЩlogÎļþµÄÄÚÈÝ£¬Äã¿ÉÒÔ°ÑËüÃÇÁ¬½ÓÆðÀ´²¢Êä³öµ½±ê×¼Êä³öÉÏ£¬¾ÍÊÇÉÏÃæµÄÀý×ÓչʾµÄ¡£ÕâºÜÓÐÓ㬵«Êä³öµÄÄÚÈÝ¿ÉÒÔ¸üÓÐÂ߼Щ¡£
sort
sort ¨C ÎļþÀïµÄÎÄ×Ö°´ÐÐÅÅÐò
¡¡¡¡´ËʱsortÃüÁîÏÔÈ»ÊÇÄã×î¼ÑµÄÑ¡Ôñ¡£
jfields$ cat order.* | sort 8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99 8:22:20 111, Order Complete 8:23:45 112, 1, Joy of Clojure, Hardcover, 29.99 8:23:50 112, Order sent to fulfillment 8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99 8:24:20 113, Refund sent to processing
¡¡¡¡¾ÍÏñÉÏÃæÀý×ÓÏÔʾµÄ£¬ÎļþÀïµÄÊý¾ÝÒѾ¾¹ýÅÅÐò¡£¶ÔÓÚһЩСÎļþ£¬Äã¿ÉÒÔ¶ÁÈ¡Õû¸öÎļþÀ´´¦ÀíËüÃÇ£¬È»¶ø£¬ÕæÕýµÄlogÎļþͨ³£ÓдóÁ¿µÄÄÚÈÝ£¬Äã²»Äܲ»¿¼ÂÇÕâ¸öÇé¿ö¡£´ËʱÄãÓ¦¸Ã¿¼ÂǹýÂ˳öijЩÄÚÈÝ£¬°Ñcat¡¢sortºóµÄÄÚÈÝͨ¹ý¹ÜµÀ´«µÝ¸ø¹ýÂ˹¤¾ß¡£
grep
grep, egrep, fgrep ¨C ´òÓ¡³öÆ¥ÅäÌõ¼þµÄÎÄ×ÖÐÐ
¡¡¡¡¼ÙÉèÎÒÃÇÖ»¶ÔPatterns of Enterprise ArchitectureÕâ±¾ÊéµÄ¶©µ¥¸ÐÐËȤ¡£Ê¹ÓÃgrep£¬ÎÒÃÇÄÜÏÞÖÆÖ»Êä³öº¬ÓÐPatterns×Ö·ûµÄ¶©µ¥¡£
jfields$ cat order.* | sort | grep Patterns 8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99 8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99
¡¡¡¡¼ÙÉèÍ˿µ¥113³öÁËһЩÎÊÌ⣬ÄãÏ£Íû²é¿´ËùÓÐÏà¹Ø¶©µ¥¡ª¡ªÄãÓÖÐèҪʹÓÃgrepÁË¡£
jfields$ cat order.* | sort | grep ":\d\d 113, " 8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99 8:24:20 113, Refund sent to processing
¡¡¡¡Äã»á·¢ÏÖÔÚgrepÉϵÄÆ¥Åäģʽ³ýÁË¡°113¡±Í⻹ÓÐһЩÆäËüµÄ¶«Î÷¡£ÕâÊÇÒòΪ113»¹¿ÉÒÔÆ¥ÅäÉÏÊéÄ¿»ò¼Û¸ñ£¬¼ÓÉ϶îÍâµÄ×Ö·ûºó£¬ÎÒÃÇ¿ÉÒÔ¾«È·µÄËÑË÷µ½ÎÒÃÇÏëÒªµÄ¶«Î÷¡£
¡¡¡¡ÏÖÔÚÎÒÃÇÒѾ֪µÀÁËÍË»õµÄÏêϸÐÅÏ¢£¬ÎÒÃÇ»¹ÏëÖªµÀÈÕÏúÊÛºÍÍË¿î×ܶµ«ÎÒÃÇÖ»¹ØÐÄPatterns of Enterprise ArchitectureÕâ±¾ÊéµÄÐÅÏ¢£¬¶øÇÒÖ»¹ØÐÄÊýÁ¿ºÍ¼Û¸ñ¡£ÎÒÏÖÔÚÒª×öµ½ÊÇÇгýÎÒÃDz»¹ØÐĵÄÈκÎÐÅÏ¢¡£
cut
cut ¨C ɾ³ýÎļþÖÐ×Ö·ûÐÐÉϵÄijЩÇøÓò
¡¡¡¡ÓÖҪʹÓÃgrep£¬ÎÒÃÇÓÃgrep¹ýÂ˳öÎÒÃÇÏëÒªµÄÐС£ÓÐÁËÎÒÃÇÏëÒªµÄÐÐÐÅÏ¢£¬ÎÒÃǾͿÉÒÔ°ÑËüÃÇÇгÉС¶Î£¬É¾³ý²»ÐèÒªµÄ²¿·ÖÊý¾Ý¡£
jfields$ cat order.* | sort | grep Patterns 8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99 8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99 jfields$ cat order.* | sort | grep Patterns | cut -d"," -f2,5 1, 39.99 -1, 39.99
¡¡¡¡ÏÖÔÚ£¬ÎÒÃÇ°ÑÊý¾ÝËõ¼õΪÎÒÃǼÆËãÏëÒªµÄÐÎʽ£¬°ÑÕâЩÊý¾ÝÕ³Ìùµ½ExcelÀïÁ¢¿Ì¾ÍÄܵõ½½á¹ûÁË¡£
¡¡¡¡cutÊÇÓÃÀ´Ïû¼õÐÅÏ¢¡¢¼ò»¯ÈÎÎñµÄ£¬µ«¶ÔÓÚÊä³öÄÚÈÝ£¬ÎÒÃÇͨ³£»áÓиü¸´ÔÓµÄÐÎʽ¡£¼ÙÉèÎÒÃÇ»¹ÐèÒªÖªµÀ¶©µ¥µÄID£¬ÕâÑù¿ÉÒÔÓÃÀ´¹ØÁªÏà¹ØµÄÆäËûÐÅÏ¢¡£ÎÒÃÇÓÃcut¿ÉÒÔ»ñµÃIDÐÅÏ¢£¬µ«ÎÒÃÇÏ£Íû°ÑID·Åµ½ÐеÄ×îºó£¬Óõ¥ÒýºÅ°üÉÏ¡£
sed
sed ¨C Ò»¸öÁ÷±à¼Æ÷¡£ËüÊÇÓÃÀ´ÔÚÊäÈëÁ÷ÉÏÖ´Ðлù±¾µÄÎı¾±ä»»¡£
¡¡¡¡ÏÂÃæµÄÀý×ÓչʾÁËÈçºÎÓÃsedÃüÁî±ä»»ÎÒÃǵÄÎļþÐУ¬Ö®ºóÎÒÃÇÔÚÔÙÓÃcutÒƳýÎÞÓõÄÐÅÏ¢¡£
jfields$ cat order.* | sort | grep Patterns \ >| sed s/"[0-9\:]* \([0-9]*\)\, \(.*\)"/"\2, '\1'"/ 1, Patterns of Enterprise Architecture, Kindle edition, 39.99, '111' -1, Patterns of Enterprise Architecture, Kindle edition, 39.99, '113' lmp-jfields01:~ jfields$ cat order.* | sort | grep Patterns \ >| sed s/"[0-9\:]* \([0-9]*\)\, \(.*\)"/"\2, '\1'"/ | cut -d"," -f1,4,5 1, 39.99, '111' -1, 39.99, '113'
¡¡¡¡ÎÒÃǶÔÀý×ÓÖÐʹÓõÄÕýÔò±í´ïʽ¶à˵¼¸¾ä£¬²»¹ýҲûÓÐʲô¸´Ôӵġ£ÕýÔò±í´ïʽ×öÁËÏÂÃ漸ÖÖÊÂÇé
- ɾ³ýʱ¼ä´Á
- ²¶×½¶©µ¥ºÅ
- ɾ³ý¶©µ¥ºÅºóµÄ¶ººÅºÍ¿Õ¸ñ
- ²¶×½ÓàϵÄÐÐÐÅÏ¢
¡¡¡¡ÀïÃæµÄÒýºÅºÍ·´Ð±¸ÜÓеãÂÒ£¬µ«Ê¹ÓÃÃüÁîÐÐʱ±ØÐëÒªÓõ½ÕâЩ¡£
¡¡¡¡Ò»µ©²¶×½µ½ÁËÎÒÃÇÏëÒªµÄÊý¾Ý£¬ÎÒÃÇ¿ÉÒÔʹÓà \1 & \2 À´´æ´¢ËüÃÇ£¬²¢°ÑËüÃÇÊä³ö³ÉÎÒÃÇÏëÒªµÄ¸ñʽ¡£ÎÒÃÇ»¹ÔÚÆäÖмÓÈëÁËÒªÇóµÄµ¥ÒýºÅ£¬ÎªÁ˱£³Ö¸ñʽͳһ£¬ÎÒÃÇ»¹¼ÓÈëÁ˶ººÅ¡£×îºó£¬ÓÃcutÃüÁî°Ñ²»±ØÒªµÄÊý¾Ýɾ³ý¡£
¡¡¡¡ÏÖÔÚÎÒÃÇÓÐÂé·³ÁË¡£ÎÒÃÇÉÏÃæÒѾÑÝʾÁËÈçºÎ°ÑlogÎļþÏû¼õ³É¸ü¼ò½àµÄ¶©µ¥ÐÎʽ£¬µ«ÎÒÃǵIJÆÎñ²¿ÃÅÐèÒªÖªµÀ¶©µ¥ÀïÒ»¹²ÓÐÄÄЩÊé¡£
uniq
uniq ¨C ɾ³ýÖظ´µÄÐÐ
¡¡¡¡ÏÂÃæµÄÀý×ÓչʾÁËÈçºÎ¹ýÂ˳ö¸úÊéÏà¹ØµÄ½»Ò×£¬É¾³ý²»ÐèÒªµÄÐÅÏ¢£¬»ñµÃÒ»¸ö²»Öظ´µÄÐÅÏ¢¡£
jfields$ cat order.out.log | grep "\(Kindle\|Hardcover\)" | cut -d"," -f3 | sort | uniq -c 1 Joy of Clojure 2 Patterns of Enterprise Architecture
¡¡¡¡¿´ÆðÀ´ÕâÊÇÒ»¸öºÜ¼òµ¥µÄÈÎÎñ¡£
¡¡¡¡ÕⶼÊǺܺÃÓõÄÃüÁµ«Ç°ÌáÊÇÄãÒªÄÜÕÒµ½ÄãÏëÒªµÄÎļþ¡£ÓÐʱºòÄã»á·¢ÏÖһЩÎļþ²ØÔÚºÜÉîµÄÎļþ¼ÐÀÄã¸ù±¾²»ÖªµÀËüÃÇÔÚÄÄ¡£µ«Èç¹ûÄãÊÇÖªµÀÄãҪѰÕÒµÄÎļþµÄÃû×ֵĻ°£¬Õâ¶ÔÄã¾Í²»ÊǸöÎÊÌâÁË¡£
find
find ¨C ÔÚÎļþĿ¼ÖÐËÑË÷Îļþ
¡¡¡¡ÔÚÉÏÃæµÄÀý×ÓÖÐÎÒÃÇ´¦ÀíÁËorder.in.logºÍorder.out.logÕâÁ½¸öÎļþ¡£ÕâÁ½¸öÎļþ·ÅÔÚÎÒµÄhomeĿ¼ÀïµÄ¡£ÏÂÃæÁËÀý×Ó½«Ïò´ó¼ÒչʾÈçºÎÔÚÒ»¸öºÜÉîµÄĿ¼½á¹¹ÀïÕÒµ½ÕâÑùµÄÎļþ¡£
jfields$ find /Users -name "order*" Users/jfields/order.in.log Users/jfields/order.out.log
¡¡¡¡findÃüÁîÓкܶàÆäËüµÄ²ÎÊý£¬µ«99%µÄʱ¼äÀïÎÒÖ»ÐèÒªÕâÒ»¸ö¾Í¹»ÁË¡£
¡¡¡¡¼òµ¥µÄÒ»ÐУ¬Äã¾ÍÄÜÕÒµ½ÄãÏëÒªµÄÎļþ£¬È»ºóÄã¿ÉÒÔÓÃcat²é¿´Ëü£¬ÓÃcutÐÞ¼ôËü¡£µ«ÎļþºÜСʱ£¬ÄãÓùܵÀ°ÑËüÃÇÊä³öµ½ÆÁÄ»ÉÏÊÇ¿ÉÒԵģ¬µ«µ±Îļþ´óµ½³¬³öÆÁĻʱ£¬ÄãÒ²ÐíÓ¦¸ÃÓùܵÀ°ÑËüÃÇÊä³ö¸ølessÃüÁî¡£
less
less ¨C ÔÚÎļþÀïÏòÇ°»òÏòºóÒƶ¯
¡¡¡¡ÈÃÎÒÃÇÔٻص½¼òµ¥µÄ cat | sort Àý×ÓÖÐÀ´£¬ÏÂÃæµÄÃüÁî¾ÍÊǽ«¾¹ýºÏ²¢¡¢ÅÅÐòºóµÄÄÚÈÝÊä³öµ½lessÃüÁîÀï¡£ÔÚ less ÃüÁʹÓá°/¡±À´Ö´ÐÐÏòÇ°ËÑË÷£¬Ê¹Óá°£¿¡±ÃüÁîÖ´ÐÐÏòºóËÑË÷¡£ËÑË÷Ìõ¼þÊÇÒ»¸öÕýÔò±í´ïʽ¡£
jfields$ cat order* | sort | less
¡¡¡¡Èç¹ûÄãÔÚ less ÃüÁîÀïʹÓà /113.*£¬ËùÓÐ113¶©µ¥µÄÐÅÏ¢¶¼»á¸ßÁÁ¡£ÄãÒ²¿ÉÒÔÊÔÊÔ?.*112£¬ËùÓиú¶©µ¥112Ïà¹ØµÄʱ¼ä´Á¶¼»á¸ßÁÁ¡£×îºóÄã¿ÉÒÔÓà ¡®q¡¯ À´Í˳ölessÃüÁî¡£
¡¡¡¡linuxÀïÓкܷḻµÄ¸÷ÖÖÃüÁÓÐЩÊǺÜÄÑÓõġ£È»¶ø£¬Ñ§»áÁËÇ°Ãæ˵µÄÕâ8¸öÃüÁÄãÒѾÄÜ´¦Àí´óÁ¿µÄlog·ÖÎöÈÎÎñÁË£¬ÍêÈ«²»ÐèÒªÓýű¾ÓïÑÔд³ÌÐòÀ´´¦ÀíËüÃÇ¡£
ÍƼöÐÅÏ¢
- linuxÃüÁîѧϰ±Ê¼Ç£¨11£©£ºnlÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨5£©£ºrmÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨4£©£ºmkdirÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨1£©£ºlsÃüÁî
- ½«CentosµÄyumÔ´¸ü»»Îª¹úÄڵİ¢ÀïÔÆÔ´
- ʹÓÃNginxÌí¼Óheader·ÀÖ¹ÍøÒ³±»frame
- linuxϼÓËÙscp´«Êä´óÎļþµÄËÙ¶È
- linuxϵͳÉ϶ÔnginxÈÕÖ¾·Ö¸î´¦Àí
- lnmp/nginxϵͳÕæÕýÓÐЧµÄͼƬ·ÀµÁÁ´ÍêÕûÉèÖÃÏê½â
- Í»ÆÆÊ®Íò²¢·¢µÄNginxµÄÅäÖü°ÓÅ»¯
ÈÈÃÅÐÅÏ¢
- nohup: redirecting stderr to stdou....
- ʹÓÃlog_formatΪNginx·þÎñÆ÷ÉèÖøüÏêϸµÄÈÕÖ¾¸ñʽ
- jquery easyUI--dataGrid-Json
- [Ô´´]·ÂGoogle Reader¡¢ÐÂÀË΢²©¡¢ÌÚѶ΢²©µ....
- ÀûÓÃKeepalived+mysql¹¹½¨¸ß¿ÉÓÃMySQLË«Ö÷×Ô¶....
- Nginx+keepalivedʵÏÖ¸ºÔؾùºâºÍË«»úÈȱ¸¸ß¿ÉÓÃ
- jqueryʵÏÖÒ³Ãæ¼ÓÔؽø¶ÈÌõ
- Rolling cURL: PHP²¢·¢×î¼Ñʵ¼ù
- codeigniter ·ÓÉÖÕ¼«ÓÅ»¯(url rewrite)
- linuxÏÂÉèÖÃsshÎÞÃÜÂëµÇ¼
×î½ü¸üÐÂ
- ²éÕÒ²¢É¾³ý.svnĿ¼Îļþ
- redis ÆßÖÖÊý¾ÝÀàÐ͵ÄʹÓó¡¾°
- linux ÏÂÎļþ¸´ÖƵ½windowsÏÂÂÒÂëµÄ½â¾ö°ì·¨
- nginx³öÏÖ502 upstream sent too big he....
- linuxÏÂsudoÅäÖÃÏê½â
- linuxÃüÁîѧϰ±Ê¼Ç£¨15£©£ºtailÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨14£©£ºheadÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨13£©£ºlessÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨12£©£ºmoreÃüÁî
- ¼ÓÃÜËã·¨±È½Ï3DES AES RSA ECC MD5 SHA1µÈ
ÆÀÂÛ