0
內容包含從文件中讀取的字符串。我想要做的是用組和換行符替換捕獲組。但我不知道如何。BASH:使用sed替換字符串中的組
這工作
contents=$(echo $contents | sed -e 's|/$(#.*)\n||g')
但這並不
contents=$(echo $contents | sed -e 's|/$(#.*)\n|\1\n|g')
ERROR: sed: -e expression #1, char 18: invalid reference \1 on `s' command's RHS
而且也沒有這個
contents=$(echo $contents | sed -er 's|/$(#.*)\n|\1\n|g')
ERROR: sed: can't read s|/$(#.*)\n|\1\n|g: No such file or directory
請提供示例輸入和所需輸出。 – dawg
'$'被視爲特殊的「行尾」字符?在這種情況下,什麼都沒有匹配......你需要逃避角色。 –