zoukankan      html  css  js  c++  java
  • sed替换配置文件

    中文符号改英文

    sed -ri  -e 's#。#.#g' 
    			-e 's#“#"#g' 
    			-e 's#”#"#g' 
    			-e 's#,#,#g' 
    			-e 's#?#?#g' 
    			-e 's#《#<#g' 
    			-e 's#》#>#g' 
    			-e 's#:#:#g' 
    			-e 's#—#-#g' 
    			-e 's#(#(#g' 
    			-e 's#)#)#g' 
    			-e 's#、#\#g' 
    			-e 's#;#;#g' 
    			-e 's#……#...#g' 123.txt
    
    sed -r -e "s#(.*ip: ).*#199.199.10.102#g" application.yml
    sed -r -e "s#(.*ip: ).*#1199.199.10.102#g" application.yml
    sed -r -e "s#(ip: ).*#1199.199.10.102#g" application.yml
    
    
    sed -r -e "s#(ip: ).*#1199.199.10.102#g" -e "s#(url: jdbc:mysql://).*(?useUnicode=true&characterEncoding=UTF8)#1192.168.1.217:3306/devops2#g" application.yml
    sed -r -e "s#(ip: ).*#1199.199.10.102#g" -e "s#(url: jdbc:mysql://).*(?useUnicode=true&characterEncoding=UTF8)#1192.168.1.217:3306/devops2#g" application.yml
    sed -r -e "s#(ip: ).*#1199.199.10.102#g" -e "s#(url: jdbc:mysql://).*(?useUnicode=true&characterEncoding=UTF8)#1192.168.1.217:3306/devops2#g" application.yml
    sed -r -e "s#(ip: ).*#1199.199.10.102#g" -e "s#(url: jdbc:mysql://).*(?useUnicode=true&characterEncoding=UTF8)#1devops2#g" application.yml
    sed -r -e "s#(url: jdbc:mysql://).*(?useUnicode=true&characterEncoding=UTF8)#1devops2#g" application.yml
    sed -r -e "s#(url: jdbc:mysql://).*(?useUnicode=true&characterEncoding=UTF8)#1devops2#g" application.yml
    sed -r -e "s#(ip: ).*#1199.199.10.102#g" -e "s#(url: jdbc:mysql://).*(?useUnicode=true&characterEncoding=UTF8)#1192.168.1.217:3306/devops2#g" application.yml
    
    
    #替换logback-spring.xml日志目录
    
    sed -r -e 's#(<property name="LOG_HOME" value=").*(" />)#1/devops/logs2#g' logback-spring.xml
    # 替换所有xml文件(-r -i顺序不能乱)
    sed -rie 's@(<property name="LOG_HOME" value=").*(" />)@1/devops/logs2@g' */logback-spring.xml
    
    
    # 替换application.yml文件
    ## 1.webapps
    sed -rie 's#^(  webapps-path: /).*#1devops/webapps/#g' */application.yml
    ## 2.mongodb-uri: 
    sed -rie 's#^(      uri: mongodb://).*(:27017/).*#1admin:admin123@127.0.0.12devops#g' */application.yml
    
    ## 3. mysql
    ###(1)name
    sed -rie 's#^(    name: )autochain.*#1devops#g' */application.yml
    ###(2)url
    # sed -rie 's#^(    url: jdbc:mysql://).*(:3306/).*(?useUnicode=true&characterEncoding=UTF8)#1127.0.0.12devops3#g' */application.yml
    sed -rie 's#^(    url: jdbc:mysql://).*(?useUnicode=true&characterEncoding=UTF8)#1127.0.0.1:3306/devops2#g' */application.yml
    
    ###(3)username
    sed -rie 's#^(    username: )jet.*#1devops#g' */application.yml
    sed -rie 's#^(    username: )dev.*#1devops#g' */application.yml
    ###(4)password
    sed -rie 's#^(    password: )jet.*#1thisispassword#g' */application.yml
    sed -rie 's#^(    password: )Mic.*#1thisispassword#g' */application.yml
    
    
    ## 4. jedis
    
    ###(1)rabbitMQ&redis
    sed -rie 's#^(    host: ).*#1127.0.0.1#g' */application.yml
    
    
    ###(1.2)rabbitMQ.address
    sed -rie 's#^(    address: ).*(:5672)#1127.0.0.12#g' */application.yml
    
    ###(2)password
    sed -rie 's#^(    password:)$#1 admin#g' */application.yml
    ## 5. resource
    ###(1)
    sed -rie 's#^(  ip: ).*$#1199.199.10.102#g' */application.yml
    ## 6. licenses
    ###(1)
    sed -rie 's#^(  licPath: ).*#1/devops/licenses#g' */application.yml
    
    
    
    
    #####################################################
    #####################################################
    #汇总
    sed -ri 's@(<property name="LOG_HOME" value=").*(" />)@1/devops/logs2@g' */logback-spring.xml
    sed -ri 's#^(  webapps-path: /).*#1devops/webapps/#g' */application.yml
    sed -ri 's#^(      uri: mongodb://).*(:27017/).*#1admin:admin123@127.0.0.12devops#g' */application.yml
    sed -ri 's#^(    name: )autochain.*#1devops#g' */application.yml
    sed -ri 's#^(    url: jdbc:mysql://).*(?useUnicode=true&characterEncoding=UTF8)#1127.0.0.1:3306/devops2#g' */application.yml
    sed -ri 's#^(    username: )jet.*#1devops#g' */application.yml
    sed -ri 's#^(    username: )dev.*#1devops#g' */application.yml
    sed -ri 's#^(    password: )jet.*#1thisispassword#g' */application.yml
    sed -ri 's#^(    password: )Mic.*#1thisispassword#g' */application.yml
    sed -ri 's#^(    host: ).*#1127.0.0.1#g' */application.yml
    sed -ri 's#^(    address: ).*(:5672)#1127.0.0.12#g' */application.yml
    sed -ri 's#^(    password:)$#1 admin#g' */application.yml
    sed -ri 's#^(  ip: ).*$#1199.199.10.102#g' */application.yml
    sed -ri 's#^(  licPath: ).*#1/devops/licenses#g' */application.yml
    
    # 单行
    
    sed -ri 's@(<property name="LOG_HOME" value=").*(" />)@1/devops/logs2@g' */logback-spring.xml
    sed -ri -e 's#^(  webapps-path: /).*#1devops/webapps/#g' 
    		-e 's#^(      uri: mongodb://).*(:27017/).*#1admin:admin123@127.0.0.12devops#g' 
    		-e 's#^(    name: )autochain.*#1devops#g' 
    		-e 's#^(    url: jdbc:mysql://).*(?useUnicode=true&characterEncoding=UTF8)#1127.0.0.1:3306/devops2#g' 
    		-e 's#^(    username: )jet.*#1devops#g' 
    		-e 's#^(    username: )dev.*#1devops#g' 
    		-e 's#^(    password: )jet.*#1thisispassword#g' 
    		-e 's#^(    password: )Mic.*#1thisispassword#g' 
    		-e 's#^(    host: ).*#1127.0.0.1#g' 
    		-e 's#^(    address: ).*(:5672)#1127.0.0.12#g' 
    		-e 's#^(    password:)$#1 admin#g' 
    		-e 's#^(  ip: ).*$#1199.199.10.102#g' 
    		-e 's#^(  licPath: ).*#1/devops/licenses#g' */application.yml
    
    
  • 相关阅读:
    vue内置指令与自定义指令
    javascript全局方法与变量
    javascript继承
    promise对象
    javascript函数节流(throttle)与函数去抖(debounce)
    Mysql Explain 解读(基于MySQL 5.6.36)
    Mycat之日志分析跨分片事务以及存储过程的执行过程
    Mycat之日志分析 select * from travelrecord order by id limit 100000,100 的执行过程
    Mycat实战之离散分片
    Mycat实战之连续分片
  • 原文地址:https://www.cnblogs.com/jrri/p/14390800.html
Copyright © 2011-2022 走看看