System Administration: June 2007 Archives
通过perl来给log里带有特殊单词的行加上颜色,带颜色的log更易于识别和阅读。
#!/usr/bin/env perl
while(<STDIN>) {
s/($ARGV[0])/\033[1m\033[45m\1\033[0m/g if $ARGV[0];
print "\033[1m\033[37m\033[41m" if /error/i;
print "\033[1m\033[32m" if /info/i;
print "\033[1m\033[32m" if /notice/i;
print "\033[1m\033[36m" if /warn/i;
print $_;
print "\033[0m";
}
Search
October 2008
Friends
Recent Posts
Tag Cloud
- acm
- algorithm
- apache
- bash
- basketball
- bitlbee
- blog
- book
- boot
- camera
- cnlexizer
- computer vision
- console
- daemon
- daemontools
- debian
- directx
- dll
- dotNet
- dynamic programming
- eating
- eduos
- embedded
- evc
- eye candy
- fastcgi
- firefox
- framebuffer
- freebsd
- fs
- git
- grep
- hardware
- ifconfig
- im
- inputrc
- json
- kernel
- life
- linux
- maintainance
- math
- moluser
- msmtp
- mutt
- network
- nfs
- nlp
- notebook
- patch
- performance
- perl
- php
- printf
- regex
- router
- rxvt-unicode
- scp
- screen
- sexy
- shell
- slackware
- smartphone
- ssh
- ssl
- svn
- sysrq
- toshiba
- tunnel
- urxvt
- vc
- vcs
- vfw
- wallpaper
- windows
- xargs
Categories
Powered by Movable Type
Recent Comments
FW on 【转】rxvt-unicode (urxvt) 字间距过宽的patch: pls contac
jianingy on 用正则表达式Look-Ahead做带逃逸的变量替换: 这个lc是啥意思?
cnhackTNT on 用正则表达式Look-Ahead做带逃逸的变量替换: 晕,被过滤掉了,再试
cnhackTNT on 用正则表达式Look-Ahead做带逃逸的变量替换: s/(? 这样可以
R.Q. on 个性化SSH登录: 酱紫哦,了了 ---