小编Coo*_*007的帖子

如何根据匹配的搜索值grep特定值

我需要帮助"db-unique-name"才能找到lifecycle-state": "AVAILABLE".

cat db_systems.txt

     "db-unique-name": "p00z5bj_iad2bj",
      "db-workload": "OLTP",
      "defined-tags": {},
      "freeform-tags": {},
      "id": "dfadfasfsadfasdfasdf",
      "lifecycle-details": null,
      "lifecycle-state": "AVAILABLE",
--
      "db-unique-name": "p00u5bh_iad2bj",
      "db-workload": "OLTP",
      "defined-tags": {},
      "freeform-tags": {},
      "id": "asdfsadfasdfasfd",
      "lifecycle-details": "Resource was terminated at the backend.",
      "lifecycle-state": "FAILED",
--
      "db-unique-name": "p00u5bh_iad2bj",
      "db-workload": "OLTP",
      "defined-tags": {},
      "freeform-tags": {},
      "id": "asdfasdfasdf",
      "lifecycle-details": "Resource was terminated at the backend.",
      "lifecycle-state": "FAILED",
    enter code here
Run Code Online (Sandbox Code Playgroud)

"db-unique-name"基于 的尝试值"lifecycle-state": "AVAILABLE"。以下,但它给出了错误的价值

cat db_systems.txt  |  egrep -A -6  "lifecycle-state|AVAILABLE" | grep …
Run Code Online (Sandbox Code Playgroud)

grep awk text-processing

5
推荐指数
2
解决办法
366
查看次数

标签 统计

awk ×1

grep ×1

text-processing ×1