[英]Gnu sed removes single quotes
The problem is that sed removes single quotes besides they are not mentioned in the matching pattern: 问题是sed会删除单引号,除了匹配模式中未提及的单引号:
echo "aaa 'w' ddd" | sed -r 's/aaa/echo dd/ge'
results in 结果是
dd w ddd
Do you have any explanation on this? 您对此有何解释?
The "e" at the end is causing it. 末尾的“ e”是引起它的原因。 Essentially, you are asking sed to do this: 本质上,您要求sed执行此操作:
echo dd 'w' ddd
which will produce the results you see. 这将产生您看到的结果。 You could do something like this: 您可以执行以下操作:
echo $(echo "aaa 'w' ddd" | sed -e 's/aaa/dd/g')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.