0
我的.profile文件中有一个RESLOC变量,该变量会随时更改。所以我写了一个脚本,只需从用户输入新名称。从ksh中的另一个脚本采购.profile
猫tst.sh
echo "Enter the Result Location name where you would like your results to go."
read RESL
perl -pi.bak -e "s/([\s]+)RESLOC=\/result\/([\S]+)/$1 RESLOC=\/result\/${RESL}/g" /user/.profile
cd /user
. /user/.profile
echo "$RESLOC"
最后echo语句使输出由用户给定的值。 但是,当我在终端中执行了脚本之后执行echo $ RESLOC时,它会显示旧值。
O /脚本的病人:
Enter the Result Location name where you would like your results to go.
Release12
/user/Release12
当执行完成后,尝试显示RESLOC。
echo $RESLOC
/user/Release11
.profile文件已被Release12更新。但它没有正确的来源。 请帮忙。