bash获取properties文件资源

#!/bin/sh

prop_value=""
function getProperty()
{
    file=$1
        prop_key=$2
        prop_value=`cat $file | grep -w ^${prop_key} | cut -d= -f2`
}
getProperty $1 $2
echo $prop_value
age=23
sex=男

运行

./GetProperty.sh test.cfg age

输出23

posted @ 2016-01-03 11:25  豆苗稀  阅读(574)  评论(0编辑  收藏  举报