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
    
    
  • 相关阅读:
    水平居中、垂直居中,总有一款适合你的
    HTML利用posotion属性定位 小技巧
    angular2 如何使用websocket
    angular2 引入jquery
    HTML+CSS学习笔记
    用eclipse 搭建struts2环境
    html对URL传参数进行解析
    angular2上传图片
    当div元素内的内容超出其宽度时,自动隐藏超出的内容
    关于引用对象的使用的一点小理解
  • 原文地址:https://www.cnblogs.com/jrri/p/14390800.html
Copyright © 2011-2022 走看看