zoukankan      html  css  js  c++  java
  • linux 修改 properties

    getValue 方法:

    从 config.properties 配置文件中 根据 pname 来获取value :

    1 api_1=t_burberry_sales_daily
    2 api_2=bz_return_order
    3 api_3=bz_return_order_line
    View Code
     1 #!/bin/bash
     2 getvalue(){
     3 
     4 if [ $# -ne 2 ];then
     5         echo "you must put one parmes"
     6         exit 1
     7     fi
     8     typeset file=$1
     9        typeset key=$2
    10     value=`awk -F= -v k=${key} '{ if ( $1 == k ) print $2; }' $file`
    11     if [ $? -ne 0 ];then
    12                 echo " para config.properties file failed"       
    13         exit 1
    14     else
    15         if [ "x${value}" = "x" ];then
    16             exit 1
    17         fi
    18 fi
    19        
    20 echo "$value"
    21 }
    22 getvalue $1 $2
    View Code

     Set 方法:

    属性文件 api.properties

    • api_1=t_burberry_sales_daily
    • api_2=bz_return_order
    • api_3=bz_return_order_line

    需求:先需要通过shell 脚本将 api_1 的value值替换为 targetValue ;
    实现方式:

    • sed -i "s#^api_1=.*#api_1=apiName#g" /path
  • 相关阅读:
    keepalived+httpd 高可用
    网卡绑定配置文件
    elk安装
    mysql数据库
    sed
    kvm
    日常巡检
    haproxy
    (6)PY_(study)
    (5)PY_(study)
  • 原文地址:https://www.cnblogs.com/linbo3168/p/14129511.html
Copyright © 2011-2022 走看看