我正在尝试执行一个带有变量的wget命令,但它只是忽略它,不知道我做错了什么?
#!/bin/bash
URL=http:://www.myurl.com
echo $(date) 'Running wget...'
wget -O - -q "$URL/something/something2"
解决方法:
四件事:
>在您的网址周围添加引号:http :: //www.myurl.com ==> “HTTP :: //www.myurl.com”
>删除双冒号:“http :: //www.myurl.com”==> “http://www.myurl.com”
>摆脱wget命令中的额外标志和连字符:“wget -O – -q”$URL / something / something2“”==> wget“$URL / something / something2”
>在变量周围添加花括号:“wget”$URL / something / something2“”==> “wget”${URL} / something / something2“”
这有效:
#!/bin/bash
URL="http://www.google.com"
echo $(date) 'Running wget...'
wget "${URL}"
标签:bash,linux
来源: https://codeday.me/bug/20190829/1764007.html