TransWikia.com

How to grep a identical word in json file format

Ask Ubuntu Asked by allada01 on November 18, 2021

Here is my command:

aws logs describe-metric-filters --log-group-name mahi | jq '.metricFilters[].metricTransformations' | grep "metricName"

output:

"metricName": "APIMetric",

"metricNamespace": "APINamespace",

From the above command i need only the metricName where it is grepping both the words which starts with metricName.

One Answer

Easiest way is to tell grep it needs to find the quotation marks too. You can avoid any escaping shenanigans by wrapping the search text in single quote marks:

aws logs describe-metric-filters --log-group-name mahi | jq '.metricFilters[].metricTransformations' | grep '"metricName"'

Answered by Dan Scally on November 18, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP