我试图从包含句点(.)的shell脚本中读取属性文件角色如下:
# app.properties
db.uat.user=saple user
db.uat.passwd=secret
#/bin/sh
function pause(){
read -p "$*"
}
file="./app.properties"
if [ -f "$file" ]
then
echo "$file found."
. $file
echo "User Id " $db.uat.user
echo "user password =" $db.uat.passwd
else
echo "$file not found."
fi
我试图在获取文件后解析该文件,但由于密钥包含"."而无法工作字符,该值中也有空格.
我的属性文件始终位于脚本的同一目录或/usr/share/doc中的某个位置