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
'$'被视为特殊的“行尾”字符?在这种情况下,什么都没有匹配......你需要逃避角色。 –