linux shell读取配置文件

配置文件CoverageInfo

FTP_URL=ftp://svn-fb.sicent.com:21/jenkins/Jifei_Repo/OL-2/IDC_Platform/bar_seats_coverage/trunk/2016-04-06.16
FTP_USER=jenkins
FTP_PASS=jenkins
SVN_URL=https://js-yuanshengtao.sicent.corp/svn/idc-server/trunk
SVN_VER=16
BUILD_DIR=/home/liouys/idc-linux/bar_seats_coverage/build

我们需要获取配置文件里面的值,有下列方法:

方法一:

#!/bin/bash

source CoverageInfo 

echo $FTP_URL
echo $FTP_USER
echo $FTP_PASS
echo $SVN_URL
echo $SVN_VER
echo $BUILD_DIR

方法二:

#!/bin/bash

while read line;
do
    eval "$line"
done < CoverageInfo

echo $FTP_URL
echo $FTP_USER
echo $FTP_PASS
echo $SVN_URL
echo $SVN_VER
echo $BUILD_DIR

转载自https://www.cnblogs.com/ChinaHook/p/6754420.html?tdsourcetag=s_pctim_aiomsg

你可能感兴趣的:(Linux)