【发布时间】:2014-10-17 11:45:25
【问题描述】:
我的 .profile 文件中有一个 RESLOC 变量,它会不时更改。所以我写了一个脚本,只是从用户那里获取新名称的输入。
猫 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 语句将输出作为用户给出的值。 但是当我在终端中执行脚本后回显 $RESLOC 时,它会显示旧值。
脚本的O/P:
Enter the Result Location name where you would like your results to go.
Release12
/user/Release12
执行完成后尝试显示RESLOC时。
echo $RESLOC
/user/Release11
.profile 文件已随 Release12 更新。但它的来源不正确。 请帮忙。
【问题讨论】:
标签: ksh substitution .profile