zoukankan      html  css  js  c++  java
  • substitute Chapter to Ch and chapter to ch in springboot idea project

    1 relative skills

    1.1 linux批量替换目录下所有文件中的某字符串

    1. method1: 比如,要将目录/modules下面所有文件中的zhangsan都修改成lisi,这样做:
      sed -i "s/zhangsan/lisi/g" `grep zhangsan -rl /modules`

    解释一下:
    -i 表示inplace edit,就地修改文件
    -r 表示搜索子目录
    -l 表示仅输出匹配的文件名,不输出匹配到的那一行的具体内容

    1. method2: linux shell 字符串中指定字符替换
      echo ${"abc1234bb1234"/23/bb} //abc1bb42341 替换一次
      echo ${string//23/bb} //abc1bb4bb41 双斜杠替换所有匹配
      echo ${string/#abc/bb} //bb12342341 #以什么开头来匹配,根php中的^有点像
      echo ${string/%41/bb} //abc123423bb %以什么结尾来匹配,根php中的$有点像

    1.2 批量更改目录下所有文件名(如修改后缀名)

    1. method1: 命令格式: rename 's/.csv/.txt/' *
      我想把当前目录下所有的txt文件都修改为后缀为csv,如果一个一个的修改,很耗费时间,效率低,只要执行这个命令,一下就搞定。

    2. method2: for i in 3_*; do mv $i $i".txt"; done
      利用for循环,遍历所有有特定特征的文件,然后给其重命名。

    2 steps

    2.1 substitute folder names: chapter to ch

    1. target folders:
      /d/develop/ideaws/parentProject/chapter*
      find /d/develop/ideaws/parentProject/ -name *chapter*
      (actually, folders whose name contains chapter only exists in /d/develop/ideaws/parentProject/chapter*, so we don't need to handle find /d/develop/ideaws/parentProject/ -name *chapter* )

    2. monitor the effect in advance
      for i in /d/develop/ideaws/parentProject/*; do echo ${i/chapter/ch}; done

    3. substitute
      for i in /d/develop/ideaws/parentProject/*; do mv $i ${i/chapter/ch}; done

    4. verfiy the result
      ll /d/develop/ideaws/parentProject/

    2.2 substitute folder names: Chapter to Ch

    1. target folders:
      find /d/develop/ideaws/parentProject/ -name *Chapter*
    2. monitor the effect in advance
      for i in `find /d/develop/ideaws/parentProject/ -name *Chapter*`; do echo ${i/Chapter/Ch}; done
    3. substitute
      for i in `find /d/develop/ideaws/parentProject/ -name *Chapter*`; do mv $i ${i/Chapter/Ch}; done
    4. verfiy the result
      find /d/develop/ideaws/parentProject/ -name *Chapter*
      find /d/develop/ideaws/parentProject/ -name *Ch*

    2.3 substitute file names: Chapter to Ch

    1. target files:
      grep Chapter -rl /d/develop/ideaws/parentProject/

    2. substitute
      sed -i "s/Chapter/Ch/g" `grep Chapter -rl /d/develop/ideaws/parentProject/`

    3. verfiy the result
      grep Chapter -rl /d/develop/ideaws/parentProject/

    2.4 substitute file names: chapter to ch

    1. target files:
      grep chapter -rl /d/develop/ideaws/parentProject/

    2. substitute
      sed -i "s/chapter/ch/g" `grep chapter -rl /d/develop/ideaws/parentProject/`

    3. verfiy the result
      grep chapter -rl /d/develop/ideaws/parentProject/

    2.5 this 3 git metadata files shoule not be substituted

    /d/develop/ideaws/parentProject/.git/index
    /d/develop/ideaws/parentProject/.git/logs/HEAD
    /d/develop/ideaws/parentProject/.git/logs/refs/heads/main

    1. method1: use old git files to replace the new files which are substituted.
      cp /d/develop/ideaws/parentProject/.git/index /d/develop/ideaws/parentProject/.git/
      cp /d/develop/ideaws/parentProject/.git/logs/HEAD /d/develop/ideaws/parentProject/.git/logs/HEAD
      cp /d/develop/ideaws/parentProject/.git/logs/refs/heads/main /d/develop/ideaws/parentProject/.git/logs/refs/heads/main

    2. method2:
      firstly move the .git/ folder to other path. after all steps complete, move back the .git/

    2.6 open idea to check whether there are other problems

    2.7 if there is no problem, submit the code with 'git commit'

  • 相关阅读:
    编写一个函数func(),将此函数的输入参数(int型)逆序输出显示,如54321 –> 12345,要求使用递归,并且函数体代码不超过8行
    java中两种单例模式
    springMVC配置freemarker 二(问题讨论篇)
    springMVC配置freemarker
    java中@value的环境配置
    java环境log4j日志环境的配置。
    websocket协议
    http报文和浏览器缓存机制
    详解网络连接
    编码总结
  • 原文地址:https://www.cnblogs.com/mediocreWorld/p/15188998.html
Copyright © 2011-2022 走看看