2
我知道在某些情況下,其他人物除了/
可以在sed
表達式中使用:使用SED刪除包含斜槓線/
sed -e 's.//..g' file
取代//
與file
空字符串,因爲我們使用.
作爲分隔器。
但是,如果您想刪除file
中匹配//comment
的行,該怎麼辦?
sed -e './/comment.d' file
回報
sed: -e expression #1, char 1: unknown command: `.'
從GNU sed的手冊頁:_' \ cregexpc':匹配與正則表達式'regexp'匹配的行。 'c'可以是任何字符._ – Cyrus
而不是使用'sed',也許'grep -v //'? –
twalberg
'grep -v'是POSIX,所以這很好 – user1011471