我在尝试DeviceId
从与以下格式类似的日志文件中获取唯一出现的 时遇到一些问题:
log: {"deviceInfo":{"DeviceId":"123","device":"Android"}
log: {"deviceInfo":{"device":"Android","DeviceId":"123"}
log: {"deviceInfo":{"device":"Android","DeviceId":"234"}
log: {"deviceInfo":{"device":"iPhone","DeviceId":"323"}
log: {"deviceInfo":{"device":"iPhone","DeviceId":"323"}
我期待的是这样的输出:
log: {"deviceInfo":{"DeviceId":"123","device":"Android"}
log: {"deviceInfo":{"device":"Android","DeviceId":"234"}
log: {"deviceInfo":{"device":"iPhone","DeviceId":"323"}
我尝试使用awk
,但我似乎可以弄清楚。有谁知道如何做到这一点?
我知道应该有一种方法来打印DeviceId
使用awk
,但我似乎无法弄清楚。一旦我得到了,DeviceId
我就可以通过管道连接到sort
and uniq
。