![在 GNU linux (SLES 11) 上的文件路径中插入变量](https://linux22.com/image/63619/%E5%9C%A8%20GNU%20linux%20(SLES%2011)%20%E4%B8%8A%E7%9A%84%E6%96%87%E4%BB%B6%E8%B7%AF%E5%BE%84%E4%B8%AD%E6%8F%92%E5%85%A5%E5%8F%98%E9%87%8F.png)
我试图插入 3 个变量来构建路径,但无法获取它。
我正在尝试以下
log_path="/vol02/logs/$dname/logs/103602_$msname/${msname}_start.log"
dname=cfp
msname=cfp003
我得到以下输出。
_start.logs/cfp/logs/103602_cfp003
我需要
/vol02/logs/cfp/logs/103602_cfp003/cfp003_start.log
答案1
尝试这个:
dname=cfp
msname=cfp003
log_path="/vol02/logs/${dname}/logs/103602_${msname}/${msname}_start.log"
echo "$log_path"
输出:
/vol02/logs/cfp/logs/103602_cfp003/cfp003_start.log