第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

如何在sed中轉(zhuǎn)義單引號(hào)?

如何在sed中轉(zhuǎn)義單引號(hào)?

SMILET 2019-11-18 14:07:25
如何在已被引號(hào)包圍的sed表達(dá)式中轉(zhuǎn)義單個(gè)引號(hào)?例如:sed 's/ones/one's/' <<< 'ones thing'
查看完整描述

3 回答

?
PIPIONE

TA貢獻(xiàn)1829條經(jīng)驗(yàn) 獲得超9個(gè)贊

sed帶雙引號(hào)的報(bào)價(jià)代碼:


    $ sed "s/ones/one's/"<<<"ones thing"   

    one's thing

我不喜歡用數(shù)百個(gè)反斜杠來(lái)轉(zhuǎn)義代碼,這很傷我的眼睛。通常我是這樣做的:


    $ sed 's/ones/one\x27s/'<<<"ones thing"

    one's thing


查看完整回答
反對(duì) 回復(fù) 2019-11-18
?
皈依舞

TA貢獻(xiàn)1851條經(jīng)驗(yàn) 獲得超3個(gè)贊

一種技巧是使用相鄰字符串的外殼程序字符串連接,并使用外殼程序轉(zhuǎn)義對(duì)嵌入式引號(hào)進(jìn)行轉(zhuǎn)義:


sed 's/ones/two'\''s/' <<< 'ones thing'


two's thing

sed表達(dá)式中有3個(gè)字符串,然后外殼將它們縫合在一起:


sed 's/ones/two'


\'


's/'


希望對(duì)別人有幫助!


查看完整回答
反對(duì) 回復(fù) 2019-11-18
?
慕斯709654

TA貢獻(xiàn)1840條經(jīng)驗(yàn) 獲得超5個(gè)贊

只需在sed命令的外部使用雙引號(hào)即可。


$ sed "s/ones/one's/" <<< 'ones thing'

one's thing

它也適用于文件。


$ echo 'ones thing' > testfile

$ sed -i "s/ones/one's/" testfile

$ cat testfile

one's thing

如果字符串中有單引號(hào)和雙引號(hào),也可以。只是轉(zhuǎn)義雙引號(hào)。


例如,此文件包含帶單引號(hào)和雙引號(hào)的字符串。我將使用sed添加單引號(hào)并刪除一些雙引號(hào)。


$ cat testfile

"it's more than ones thing"

$ sed -i "s/\"it's more than ones thing\"/it's more than one's thing/" testfile 

$ cat testfile 

it's more than one's thing


查看完整回答
反對(duì) 回復(fù) 2019-11-18
  • 3 回答
  • 0 關(guān)注
  • 2541 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)