wget使用环境变量

use*_*011 0 linux bash wget

我需要做一个wget的文件URL与一个称为Initial的变量串联在一起

但是如果我这样做,

Initial="something"

wget www.google.ca/${Initial}
Run Code Online (Sandbox Code Playgroud)

输出:

www.google.ca/$%7BInitial%7D
Run Code Online (Sandbox Code Playgroud)

我想获得所需的输出:

www.google.ca/something
Run Code Online (Sandbox Code Playgroud)

谢谢!

npa*_*pal 5

我尝试了您粘贴的代码,它可以正常工作:

Initial="something"
wget www.google.com/${Initial}
Run Code Online (Sandbox Code Playgroud)

输出为:

www.google.com/something
Run Code Online (Sandbox Code Playgroud)

您也可以尝试使用:

Initial="something"
GoogleLink="www.google.com/"$Initial
wget $GoogleLink
Run Code Online (Sandbox Code Playgroud)

和输出是相同的。

如果您复制/粘贴了脚本代码,则可能已添加了一些其他字符。这取决于您使用的编辑器。我建议您在一个新的干净文件中重新编写脚本。

编辑tvm的建议后,为了避免空格问题,请尝试:

wget "$GoogleLink"
Run Code Online (Sandbox Code Playgroud)