unable to pass wget a variable with quotes inside the variable

后端 未结 2 903
小蘑菇
小蘑菇 2020-12-22 11:40

I am trying to script a wget command to download a web page and all it\'s attachments and jpegs etc.

When I enter the script by hand, it works, but I need to run thi

相关标签:
2条回答
  • 2020-12-22 12:33

    Quotes inside of quoted strings or variables are ordinary characters, not quoting characters. There's no way to change that. Use an array instead:

    A=(a b 'c d' 'e f')
    cmd "${A[@]}"
    

    calls cmd with four arguments a, b, c d, and e f.

    (You could achieve a similar effect with eval, but that's a lot more error prone. In your case, using arrays is much more convenient.)

    0 讨论(0)
  • 2020-12-22 12:40
    session="--header=Host: mywebsite.com:9090 --header=User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:20.0) Gecko/20100101 Firefox/20.0"
    

    use this,

    0 讨论(0)
提交回复
热议问题