您好,登錄后才能下訂單哦!
本篇內容介紹了“Linux操作系統怎么解決-bash: !: event not found的問題”的有關知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領大家學習一下如何處理這些情況吧!希望大家仔細閱讀,能夠學有所成!
短字符串轉碼/解碼測試
正常轉碼(經測試,加單引號、雙引號或者不加引號的結果):
[root@db5 ~]# echo 123456 | base64 MTIzNDU2Cg== [root@db5 ~]# echo '123456' | base64 MTIzNDU2Cg== [root@db5 ~]# echo "123456" | base64 MTIzNDU2Cg== 正常解碼: [root@db5 ~]# echo MTIzNDU2Cg== | base64 -d 123456 [root@db5 ~]# echo 'MTIzNDU2Cg==' | base64 -d 123456 [root@db5 ~]# echo "MTIzNDU2Cg==" | base64 -d 123456
長字符串轉碼/解碼測試(建議使用雙引號,文中會出現單引號等字符,解析成字符串)
正常轉碼:
[root@db5 ~]# echo "May you have enough happiness to make you sweet,enough trials to make you strong,enough sorrow to keep you human,enough hope to make you happy? Always put yourself in others’soes.If you feel that it hurts you,it probably hurts the other person, too." | base64 TWF5IHlvdSBoYXZlIGVub3VnaCBoYXBwaW5lc3MgdG8gbWFrZSB5b3Ugc3dlZXQsZW5vdWdoIHRy aWFscyB0byBtYWtlIHlvdSBzdHJvbmcsZW5vdWdoIHNvcnJvdyB0byBrZWVwIHlvdSBodW1hbixl bm91Z2ggaG9wZSB0byBtYWtlIHlvdSBoYXBweT8gQWx3YXlzIHB1dCB5b3Vyc2VsZiBpbiBvdGhl cnPigJlzaG9lcy5JZiB5b3UgZmVlbCB0aGF0IGl0IGh2cnRzIHlvdSxpdCBwcm9iYWJseSBodXJ0 cyB0aGUgb3RoZXIgcGVyc29uLCB0b28uCg==
正常解碼:
[root@db5 ~]# echo "TWF5IHlvdSBoYXZlIGVub3VnaCBoYXBwaW5lc3MgdG8gbWFrZSB5b3Ugc3dlZXQsZW5vdWdoIHRy > aWFscyB0byBtYWtlIHlvdSBzdHJvbmcsZW5vdWdoIHNvcnJvdyB0byBrZWVwIHlvdSBodW1hbixl > bm91Z2ggaG9wZSB0byBtYWtlIHlvdSBoYXBweT8gQWx3YXlzIHB1dCB5b3Vyc2VsZiBpbiBvdGhl > cnPigJlzaG9lcy5JZiB5b3UgZmVlbCB0aGF0IGl0IGh2cnRzIHlvdSxpdCBwcm9iYWJseSBodXJ0 > cyB0aGUgb3RoZXIgcGVyc29uLCB0b28uCg==" | base64 -d May you have enough happiness to make you sweet,enough trials to make you strong,enough sorrow to keep you human,enough hope to make you happy? Always put yourself in others’shoes.If you feel that it hurts you,it probably hurts the other person, too.
長字符串轉碼指定—wrap參數測試**
轉碼時指定—wrap=0參數,轉碼后不換行
[root@db5 ~]# echo "May you have enough happiness to make you sweet,enough trials to make you strong,enough sorrow to keep you human,enough hope to make you happy? Always put yourself in others’ses.If you feel that it hurts you,it probably hurts the other person, too." | base64 --wrap=0 TWF5IHlvdSBoYXZlIGVub3VnaCBoYXBwaW5lc3MgdG8gbWFrZSB5b3Ugc3dlZXQsZW5vdWdoIHRyaWFscyB0byBtYWtlIHlvdSBzdHJvbmcsZW5vdWdoIHNvcnJvdyB0byBrZWVwIHlvdSBodW1hbixlbm91Z2ggaG9wZSB0byBtYWtlIHlvdSBoYXBweT8gQWx3YXlzIHB1dCB5b3Vyc2VsZiBpbiBvdGhlcnPigJlzb2VzLklmIHlvdSBmZWVsIHRoYXQgaXQgaHVydHMgeW91LGl0IHByb2JhYmx5IGh2cnRzIHRoZSBvdGhlciBwZXJzb24sIHRvby4K[root@db5 ~]#
正常解碼:
[root@db5 ~]# echo "TWF5IHlvdSBoYXZlIGVub3VnaCBoYXBwaW5lc3MgdG8gbWFrZSB5b3Ugc3dlZXQsZW5vdWdoIHRyaWFscyB0byBtYWtlIHlvdSBzdHJvbmcsZW5vdWdoIHNvcnJvdyB0byBrZWVwIHlvdSBodW1hbixlbm91Z2ggaG9wZSB0byBtYWtlIHlvdSBoYXBweT8gQWx3YXlzIHB1dCB5b3Vyc2VsZiBpbiBvdGhlcnPigJlzb2VzLklmIHlvdSBmZWVsIHRoYXQgaXQgaHVydHMgeW91LGl0IHByb2JhYmx5IGh2cnRzIHRoZSBvdGhlciBwZXJzb24sIHRvby4K" | base64 -d May you have enough happiness to make you sweet,enough trials to make you strong,enough sorrow to keep you human,enough hope to make you happy? Always put yourself in others’soes.If you feel that it hurts you,it probably hurts the other person, too.
這里說明對長字符串轉碼,通過換行參數,明確第N個字符后換行(或者不換行),可以得出不同的轉碼結果。但是對不同轉碼值進行解碼后的結果是一致的,都是原字符串。
特殊字符轉碼/解碼測試**
如果是一個特殊字符
[root@db5 ~]# echo ! | base64 IQo= [root@db5 ~]# echo '!' | base64 IQo= [root@db5 ~]# echo "!" | base64 -bash: !: event not found 如果是多個特殊字符 [root@db5 ~]# echo !@ | base64 -bash: !@: event not found [root@db5 ~]# echo '!@' | base64 IUAK [root@db5 ~]# echo "!@" | base64 -bash: !@: event not found
這里說明對特殊字符進行轉碼時,應該使用單引號。
解決-bash: !: event not found的問題
為了解決-bash: !: event not found的問題,可以執行set +H命令(set命令 參數:-H Shell 可利用”!”加
<指令編號>
的方式來執行history中記錄的指令。)
[root@db5 ~]# echo "!" | base64 -bash: !: event not found [root@db5 ~]# echo !@ | base64 -bash: !@: event not found [root@db5 ~]# echo "!@" | base64 -bash: !@: event not found [root@db5 ~]# set +H [root@db5 ~]# echo "!" | base64 IQo= [root@db5 ~]# echo !@ | base64 IUAK [root@db5 ~]# echo "!@" | base64 IUAK
“Linux操作系統怎么解決-bash: !: event not found的問題”的內容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業相關的知識可以關注億速云網站,小編將為大家輸出更多高質量的實用文章!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。