在wget bash命令中转义 [英] Escaping in wget bash command
问题描述
wget -q -T 60 --retry-connrefused -t 5 --waitretry = 60 --user = ftp2.company.com | company2013 --password =!company2013 -N -P数据/ parser / company / ftp://ftp2.company.com/Production/somedata.zip
此命令遇到问题,因为密码包含感叹号。我尝试使用进行转义,尝试使用单引号,它要么给出输出:
I'm having trouble with this command, because the password contains an exclamation mark. I tried escaping with \, tried single quotes, and it either gives the output:
wget:缺少URL
或
bash:!company2013:未找到事件
这确实令人沮丧...
This is really demotivating...
推荐答案
也许需要对此部分加引号,以防止将其视为到另一个命令的管道。
Perhaps this part needs to be quoted to prevent it from being seen as a pipe to another command.
--user='ftp2.company.com|company2013'
这也是为了防止使用!:
And this one too to prevent history expansion with !:
--password='!company2013'
最终:
wget -q -T 60 --retry-connrefused -t 5 --waitretry=60 --user='ftp2.company.com|company2013' --password='!company2013' -N -P data/parser/company/ ftp://ftp2.company.com/Production/somedata.zip
如果以后还会有空格,则引用其他部分也是一个好主意:
And it's also a good idea to quote the other parts if on later time they have spaces:
wget -q -T 60 --retry-connrefused -t 5 --waitretry=60 --user='ftp2.company.com|company2013' --password='!company2013' -N -P "data/parser/company/" "ftp://ftp2.company.com/Production/somedata.zip"
这篇关于在wget bash命令中转义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!