2013-02-27 67 views
4

我有一個變量,它是一個網址,我想,以取代在bash該網址的一部分,但我不斷收到「壞替代」BASH字符串替換給我「壞替代」

URL="http://hostname/project/branches/Old_Branch/package" 
SRC="Old_Branch" 
REP="New_Branch" 

echo ${$URL/$SRC/$REP}; 
# desired output is http://hostname/project/branches/New_Branch/package 

不知道到底我要去哪裏錯了...

回答

12
URL="http://hostname/project/branches/Old_Branch/package" 
SRC="Old_Branch" 
REP="New_Branch" 

echo "${URL/$SRC/$REP}" 

注意在${}沒有$ SIGILL爲URL =)

+1

OMG,即時通訊白癡。 – prodigitalson 2013-02-27 15:59:07