Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我只想在第一次出现时替换特殊字符 (=)。
例子:
abc=abc.def=
预期输出为:
abc.def=
我尝试了以下命令:sed -e 's/\([^=]*\)\(=.*\)/\2/' 但我得到的输出是:
sed -e 's/\([^=]*\)\(=.*\)/\2/'
=abc.def=
请注意,您的示例建议您要删除所有内容,包括第一个等号。
将等号移动到正则表达式的第一部分,删除正则表达式的剩余部分(因为您只需匹配要删除的部分)并将匹配替换为“nothing”以将其删除:
sed -e 's/^[^=]*=//'