#/bin/sh
file="C:/khushal/prop.txt"
if [ -f "$file" ]
then
echo "$file found."
while IFS= read -r key value
do
key=$(echo $key | tr '.' '_')
eval ${key}=\${value}
echo "User Id = " ${db_uat_user}
echo "user password = " ${db_uat_passwd}
else
echo "$file not found."
fi
答案1
您没有done
与该语句匹配的令牌while ... do
。
通常最好通过反转文件测试来短路脚本,这会导致 if .. then .. else 不跨越这么多行。 IE:
#/bin/sh
file="C:/khushal/prop.txt"
if ! [ -f "$file" ]
then
echo "$file not found."
exit 1
fi
echo "$file found."
while IFS= read -r key value
do
key=$(echo $key | tr '.' '_')
eval ${key}=\${value}
echo "User Id = " ${db_uat_user}
echo "user password = " ${db_uat_passwd}
done