zoukankan      html  css  js  c++  java
  • 【vi】awk为指定行的指定字段添加一个单词

    背景:每个php文件都有若干this->assert的行,这些行可能含有1个字段,可能含有多个字段;如果含有多个字段,则每个字段用,分割

    要求:在最后一个字段的开头添加上$this->UrlMonitored

    如下:

    for i in `ls *php`;do cat $i   | awk  '{if(index($0,"this->assert")) {if(index($0,",")>0)  { len=split($0,time, "," );  last=length(time[len]); print substr($0,0,length($0)-last)"$this->UrlMonitored""."time[len];}else print  substr($0,0,length($0)-2)",$this->UrlMonitored);";}else{print $0}}'  > ../case.bak/$i;ls ../case.bak/$i;done;

  • 相关阅读:
    MySQL 元数据
    MySQL 复制表
    MySQL 临时表
    MySQL 索引
    MySQL ALTER
    MySQL 事务
    MySQL 正则表达式
    Mysql Join
    Python(数据库之表操作)
    Python知识点复习之__call__
  • 原文地址:https://www.cnblogs.com/mangu-uu/p/3265820.html
Copyright © 2011-2022 走看看