shell中感嘆號與引號用法

線上環境需要定期清理緩存,如下:

[root@LB scripts]# curl http://10.238.74.31/irm/manualDataSyncPage!synchronizeCrmGroupCustomerInfo.html?UserName=004&Password=ZHzg-123   

-bash: !synchronizeCrmGroupCustomerInfo.html?UserName=004: event not found

  “!”在日常命令中可以作爲調用history歷史記錄來使用執行某行內容,在shell裏爲特殊字符。

在執行curl "http://10.238.74.31/irm/manualDataSyncPage!synchronizeCrmGroupCustomerInfo.html?UserName=004&Password=ZHzg-123"的過程中,發現“!”無法被正常解析,加上轉義反斜槓“\”也沒用。

[root@LB scripts]# curl http://10.238.74.31/irm/manualDataSyncPage\!synchronizeCrmGroupCustomerInfo.html?UserName=004&Password=ZHzg-123

-bash: !event not found

   後發現在“!”前後加入空格可以解決這個問題,但還不夠完美,因爲輸入的文件字符也是加了空格後的,感覺佔用較長地方,現象如下:

[root@LB scripts]# curl "http://10.238.74.31/irm/manualDataSyncPage ! synchronizeCrmGroupCustomerInfo.htmlme=004&Password=ZHzg-123"

   最後嘗試雙引號與反斜槓同時使用,完美解決問題!具體如下:

[root@LB scripts]# curl "http://10.238.74.31/irm/manualDataSyncPage"\!"syncronizeCrmGroupCustomerInfo.html?UserName=004&Password=ZHzg-123" 

<html>

<head>

<title>system.title</title>

<script>

var hexA0s = unescape(' %A0 %A0 %A0 %A0 %A0 %A0 %A0 %A0 %A0 %A0 %A0 %A0 %A0 %A0 %A0 %A0 %A0 %A0 %A0 %A0');

hexA0s = hexA0s + hexA0s + hexA0s + hexA0s;

hexA0s = hexA0s + hexA0s + hexA0s + hexA0s;

hexA0s = hexA0s + hexA0s + hexA0s + hexA0s;

document.title = 'system.title' + hexA0s + hexA0s;

hexA0s = null;

</script>

<meta http-equiv="Pragma" Content="No-cach"></meta>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></meta>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章