我正在尝试使用shell中的"open"命令打开一系列URL。
打开 http://www.oecd-ilibrary.org/country-statistical-profile-australia-2013-2_5k9d5vhlgxkf.xls;jsessionid=lzfo8lhxtes0.x-oecd-live-02?contentType=/ns/KeyTable,/ns/StatisticalPublication&itemId=/content/table/20752288-table-aus&containerItemId=/content/table/20752288-table-aus&accessItemIds=&mimeType=application/vnd.ms-excel
问题是,在URL中的'.xls;位之后,我认为shell认为这是URL的结尾,并尝试打开页面,并打开错误的页面。这是我的猜测,因为当我输入"echo"时,我得到:
[9] 4813
[10] 4814
[11] 4815
[12] 4816
[7] Done containerItemId=/content/table/20752288-table-aus
[8] Done accessItemIds=
[9] Done jsessionid=lzfo8lhxtes0.x-oecd-live-02?contentType=/ns/KeyTable,/ns/StatisticalPublication
[10] Done itemId=/content/table/20752288-table-aus
有没有办法确保使用整个字符串?
我不知道你用的是什么 shell,但分号通常用于分隔同一行上给出的多个命令。
您可以使用反斜杠转义分号,也可以将整个字符串放在双引号"
.
例子:
这将执行两个不同的回声,一个使用 string1
回声,另一个使用 string2
。
echo string1; echo string2
这将执行一个回显作为string1; echo string2
,因为分号是用反斜杠转义的。
echo string1; echo string2
这也将执行一个回显作为string1; echo string2
因为整个字符串在双引号之间:
echo "string1; echo string2"