#!/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
windyWu 2016-01-03 11:25 原文
#!/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