awk
awk案例1
root@rz13035:~# cat /root/grep_haproxy_log.sh
#!/bin/bash
yesterday=`date -d 'yesterday' +%Y%m%d`
tac /data/logs/haproxy.log |awk 'BEGIN {"date +%d/%b/%Y -d \"1 days ago\"" | getline a;"date +%d/%b/%Y -d \"2 days ago\"" | getline b}{if($0~a){print $0} else if($0~b){print $0;exit}}' > /data/logs/analyse_haproxy/haproxy.${yesterday}.log
微信:jinmuqq222