【发布时间】:2014-07-27 14:45:33
【问题描述】:
我想将 JSON 消息中的“电子邮件地址”差异更改为小写。我尝试使用 sed 但失败了,因为 \L 选项对我不起作用。我错过了什么吗?
a="{"id":null,"enabled":true,"password":"","email":"Foo@bar.com","lastName":"Foo","firstName":"lol"}"
echo $a | sed -e 's/email:[[:graph:]].*,last/\L&/g'
结果显示:
{id:null,enabled:true,password:,{L}email:Foo@bar.com,lastName:Foo,firstName:lol}
我想要的结果:
{id:null,enabled:true,password:,email:foo@bar.com,lastName:Foo,firstName:lol}
【问题讨论】:
-
您的代码对我有用。您可能需要指定您正在使用哪个操作系统和
sed的哪个版本。 -
你在使用 GNU sed 吗?您的代码适用于 GNU sed 4.2.1 版。要找出您使用的版本, sed --version