删除冗余信息
1sed -i 's/.*a2p_replyclient_log.*[infoerror].[0-9].log.gz://' merge.log \
2&& sed -i 's/org.springframework.amqp.rabbit.RabbitListenerEndpointContainer.* - //' merge.log \
3&& sed -i '/.*send 1 time for the url is .*/d' merge.log \
4&& sed -i '/.*redis key:[0-9]*,value:.*/d' merge.log
5
6sed -i '/>>>>.* retry:2/d' 2021.8.log
7sed -i 's/the content of the url:.*receiveStatusReportResultChinaMobile.shtml //' 2021.8.log
统计
1sed -n '/ status:DELIVRD,/p' result.log | wc -l
2sed -n '/"originalStatus":"DELIVRD"/p' merge.log | wc -l
删除毫秒
1sed -i 's/\.[0-9]\{0,3\}\( \[\)/\1/' merge.log
删除时间
1sed -i 's/.*\(\[INFO\]\)/\1/' 2021.8.log
2sed -i 's/.*\(\[ERROR\]\)/\1/' 2021.8.log
3sed -i 's/time:.*,\(is_china_mobile\)/\1/' 2021.8.log
删除冗余字符
1sed -i 's/error for the url//' merge.log
2sed -i 's/can not read content from the url//' merge.log
去重复
1$ awk '!x[$0]++' merge.log
2$ sort -n merge.log | uniq
删除空行
1$ sed -i '/^\s*$/d' merge1.log
修改Ubuntu源地址
1$ sudo sed -i 's/\(archive\|security\).ubuntu/mirrors.aliyun/' /etc/apt/sources.list
SSH连接不自动断开
1$ sed -i 's|^#\(ClientAliveInterval\) 0$|\1 60|g' /etc/ssh/sshd_config
2$ sed -i 's|^#\(ClientAliveCountMax\) 3$|\1 5|g' /etc/ssh/sshd_config
3$ systemctl restart sshd
/etc/hosts
1# sed 参考 http://man.linuxde.net/sed
2 # https://www.cnblogs.com/ggjucheng/archive/2013/01/13/2856901.html
3$ sed ......
读取指定行
参考文档