zoukankan      html  css  js  c++  java
  • sed命令

    -- 替换 空格和左圆括号为x1

    sed -i 's/ (/x1/' 0928.txt

    -- 替换 右园括号和空格和左中括号为x1
    sed -i 's/) [/x1/' 0928.txt

    2017-09-28 09:46:10.179 (5352) [50001] LOG:create global entity [RewardManager, 8]

    目标替换 (5352) [50001] LOG 为x15352x150001LOG

    2017-09-28 09:46:10.179x15352x150001LOG:create global entity [RewardManager, 8]

    ====================
    TEST:sed里面(不需要转义符,但是正则表达式的要转义符
    ====================
    echo ' (5352) [50001] LOG' | sed 's/( ()([0-9]*)() [)([0-9]*)(] )LOG/x12x14x1LOG/g'
    echo ' (5352) [50001] LOG' | sed 's/( ()([0-9]*)/x12/'

    ====================

    直接只去需要的LOG。cat选择特定日期的文件,grep选择特定的行,

    awk把前面4列去掉,再用sub把“LOG:”和之前的空格替换掉,这样某行剩下的数据都是需要的

    ====================

    cat hall.20001.log.2017-9-28 | grep '2017-.*LOG:.*|.*' | awk '{$1="";$2="";$3="";$4="";sub("    LOG:", "");print}' > 20001.txt

  • 相关阅读:
    sql刷题day03
    sql刷题day2
    sql刷题day1
    Vue学习
    HashMap学习笔记整理
    数组问题(鸽巢原理、数字交换、链表寻环)
    mybatis参数设置问题
    codeforces 327A
    codeforces 189A
    codeforces-455A
  • 原文地址:https://www.cnblogs.com/linn/p/7837416.html
Copyright © 2011-2022 走看看