Avatar

Organizations

1 results for Sed
  • 删除冗余信息

    sed -i 's/.*a2p_replyclient_log.*[infoerror].[0-9].log.gz://' merge.log \
    && sed -i 's/org.springframework.amqp.rabbit.RabbitListenerEndpointContainer.* - //' merge.log \
    && sed -i '/.*send 1 time for the url is .*/d' merge.log \
    && sed -i '/.*redis key:[0-9]*,value:.*/d' merge.log
    
    sed -i '/>>>>.* retry:2/d' 2021.8.log
    sed -i 's/the content of the url:.*receiveStatusReportResultChinaMobile.shtml //' 2021.8.log
    

    统计

    sed -n '/ status:DELIVRD,/p' result.log | wc -l
    sed -n '/"originalStatus":"DELIVRD"/p' merge.log | wc -l
    

    删除毫秒

    sed -i 's/\.[0-9]\{0,3\}\( \[\)/\1/' merge.log
    

    删除时间

    sed -i 's/.*\(\[INFO\]\)/\1/' 2021.8.log
    sed -i 's/.*\(\[ERROR\]\)/\1/' 2021.8.log
    sed -i 's/time:.*,\(is_china_mobile\)/\1/' 2021.8.log
    

    删除冗余字符

    sed -i 's/error for the url//' merge.log
    sed -i 's/can not read content from the url//' merge.log
    

    去重复

    $ awk '!x[$0]++' merge.log
    $ sort -n merge.log | uniq
    

    删除空行

    $ sed -i '/^\s*$/d' merge1.log
    

    修改Ubuntu源地址

    $ sudo sed -i 's/\(archive\|security\).ubuntu/mirrors.aliyun/' /etc/apt/sources.list
    

    SSH连接不自动断开

    $ sed -i 's|^#\(ClientAliveInterval\) 0$|\1 60|g' /etc/ssh/sshd_config
    $ sed -i 's|^#\(ClientAliveCountMax\) 3$|\1 5|g' /etc/ssh/sshd_config
    $ systemctl restart sshd
    

    /etc/hosts

    # sed 参考 http://man.linuxde.net/sed
            #  https://www.cnblogs.com/ggjucheng/archive/2013/01/13/2856901.html
    $ sed ......
    

    读取指定行

    $ sed -n '1,2p' file
    

    参考文档

    sed CLI Linux Created Mon, 17 Jan 2022 11:18:47 +0800