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
标签:haproxy,log,+%,yesterday,awk,date 来源: https://www.cnblogs.com/jinmuqq222/p/15874131.html