我如何使用任何命令来剪切命令输出

how can i use any command for cut an command output

我要剪切的命令输出:

{"logging_page_id":"profilePage_28345663","show_suggested_profiles":false,"show_follow_dialog":false,"graphql":{"user":{"biography":"","blocked_by_viewer":false,"business_email":null,"restricted_by_viewer":null,"country_block":false,"external_url":null,"external_url_linkshimmed":null,"edge_followed_by":{"count":11},"followed_by_viewer":false,"edge_follow":{"count":1},"follows_viewer":false,"full_name":"Ellen","has_ar_effects":false,"has_clips":false,"has_guides":false,"has_channel":false,"has_blocked_viewer":false,"highlight_reel_count":0,"has_requested_viewer":false,"id":"28345663","is_business_account":false,"is_joined_recently":false,"business_category_name":null,"overall_category_name":null,"category_enum":null,"is_private":false,"is_verified":false,"edge_mutual_followed_by":{"count":0,"edges":[]},"profile_pic_url":"https://instagram.fadd1-1.fna.fbcdn.net/v/t51.2885-19/11906086_160969117570026_1944988813_a.jpg?_nc_ht=instagram.fadd1-1.fna.fbcdn.net&_nc_ohc=6zVEF7PrIwcAX_x7UQ6&oh=79f8004d8b72cc242a02a703a9304a27&oe=5FAB9F39","profile_pic_url_hd":"https://instagram.fadd1-1.fna.fbcdn.net/v/t51.2885-19/11906086_160969117570026_1944988813_a.jpg?_nc_ht=instagram.fadd1-1.fna.fbcdn.net&_nc_ohc=6zVEF7PrIwcAX_x7UQ6&oh=79f8004d8b72cc242a02a703a9304a27&oe=5FAB9F39","requested_by_viewer":false,"username":"ebh14","connected_fb_page":null,"edge_felix_video_timeline":{"count":0,"page_info":{"has_next_page":false,"end_cursor":null},"edges":[]},"edge_owner_to_timeline_media":{"count":9,"page_info":{"has_next_page":false,"end_cursor":null},"edges":[{"node":{"__typename":"GraphImage","id":"202998178801934666","shortcode":"LRMcShimFK","dimensions":{"height":612,"width":6

如何在 bash 中获得这样的输出:

full name : Ellen
edge_followed_by : 1
followed_by_viewer : 11
is_business_account : false
business_email : null
is_verified : false

我尝试了像 ;

这样的命令
jq
cut 

但是我做不到我想要的

您发布的 JSON 似乎无效,因为末尾缺少一些文本(一些关闭 ]} 好像不见了)

正确的JSON是:

{"logging_page_id":"profilePage_28345663","show_suggested_profiles":false,"show_follow_dialog":false,"graphql":{"user":{"biography":"","blocked_by_viewer":false,"business_email":null,"restricted_by_viewer":null,"country_block":false,"external_url":null,"external_url_linkshimmed":null,"edge_followed_by":{"count":11},"followed_by_viewer":false,"edge_follow":{"count":1},"follows_viewer":false,"full_name":"Ellen","has_ar_effects":false,"has_clips":false,"has_guides":false,"has_channel":false,"has_blocked_viewer":false,"highlight_reel_count":0,"has_requested_viewer":false,"id":"28345663","is_business_account":false,"is_joined_recently":false,"business_category_name":null,"overall_category_name":null,"category_enum":null,"is_private":false,"is_verified":false,"edge_mutual_followed_by":{"count":0,"edges":[]},"profile_pic_url":"https://instagram.fadd1-1.fna.fbcdn.net/v/t51.2885-19/11906086_160969117570026_1944988813_a.jpg?_nc_ht=instagram.fadd1-1.fna.fbcdn.net&_nc_ohc=6zVEF7PrIwcAX_x7UQ6&oh=79f8004d8b72cc242a02a703a9304a27&oe=5FAB9F39","profile_pic_url_hd":"https://instagram.fadd1-1.fna.fbcdn.net/v/t51.2885-19/11906086_160969117570026_1944988813_a.jpg?_nc_ht=instagram.fadd1-1.fna.fbcdn.net&_nc_ohc=6zVEF7PrIwcAX_x7UQ6&oh=79f8004d8b72cc242a02a703a9304a27&oe=5FAB9F39","requested_by_viewer":false,"username":"ebh14","connected_fb_page":null,"edge_felix_video_timeline":{"count":0,"page_info":{"has_next_page":false,"end_cursor":null},"edges":[]},"edge_owner_to_timeline_media":{"count":9,"page_info":{"has_next_page":false,"end_cursor":null},"edges":[{"node":{"__typename":"GraphImage","id":"202998178801934666","shortcode":"LRMcShimFK","dimensions":{"height":612,"width":6}}}]}}}}

修复 JSON 后,jq 似乎工作正常

echo '{"logging_page_id":"profilePage_28345663","show_suggested_profiles":false,"show_follow_dialog":false,"graphql":{"user":{"biography":"","blocked_by_viewer":false,"business_email":null,"restricted_by_viewer":null,"country_block":false,"external_url":null,"external_url_linkshimmed":null,"edge_followed_by":{"count":11},"followed_by_viewer":false,"edge_follow":{"count":1},"follows_viewer":false,"full_name":"Ellen","has_ar_effects":false,"has_clips":false,"has_guides":false,"has_channel":false,"has_blocked_viewer":false,"highlight_reel_count":0,"has_requested_viewer":false,"id":"28345663","is_business_account":false,"is_joined_recently":false,"business_category_name":null,"overall_category_name":null,"category_enum":null,"is_private":false,"is_verified":false,"edge_mutual_followed_by":{"count":0,"edges":[]},"profile_pic_url":"https://instagram.fadd1-1.fna.fbcdn.net/v/t51.2885-19/11906086_160969117570026_1944988813_a.jpg?_nc_ht=instagram.fadd1-1.fna.fbcdn.net&_nc_ohc=6zVEF7PrIwcAX_x7UQ6&oh=79f8004d8b72cc242a02a703a9304a27&oe=5FAB9F39","profile_pic_url_hd":"https://instagram.fadd1-1.fna.fbcdn.net/v/t51.2885-19/11906086_160969117570026_1944988813_a.jpg?_nc_ht=instagram.fadd1-1.fna.fbcdn.net&_nc_ohc=6zVEF7PrIwcAX_x7UQ6&oh=79f8004d8b72cc242a02a703a9304a27&oe=5FAB9F39","requested_by_viewer":false,"username":"ebh14","connected_fb_page":null,"edge_felix_video_timeline":{"count":0,"page_info":{"has_next_page":false,"end_cursor":null},"edges":[]},"edge_owner_to_timeline_media":{"count":9,"page_info":{"has_next_page":false,"end_cursor":null},"edges":[{"node":{"__typename":"GraphImage","id":"202998178801934666","shortcode":"LRMcShimFK","dimensions":{"height":612,"width":6}}}]}}}}' | jq

{
  "logging_page_id": "profilePage_28345663",
  "show_suggested_profiles": false,
  "show_follow_dialog": false,
  "graphql": {
    "user": {
      "biography": "",
      "blocked_by_viewer": false,
      "business_email": null,
      "restricted_by_viewer": null,
      "country_block": false,
      "external_url": null,
      "external_url_linkshimmed": null,
      "edge_followed_by": {
        "count": 11
      },
      "followed_by_viewer": false,
      "edge_follow": {
        "count": 1
      },
      "follows_viewer": false,
      "full_name": "Ellen",
      "has_ar_effects": false,
      "has_clips": false,
      "has_guides": false,
      "has_channel": false,
      "has_blocked_viewer": false,
      "highlight_reel_count": 0,
      "has_requested_viewer": false,
      "id": "28345663",
      "is_business_account": false,
      "is_joined_recently": false,
      "business_category_name": null,
      "overall_category_name": null,
      "category_enum": null,
      "is_private": false,
      "is_verified": false,
      "edge_mutual_followed_by": {
        "count": 0,
        "edges": []
      },
      "profile_pic_url": "https://instagram.fadd1-1.fna.fbcdn.net/v/t51.2885-19/11906086_160969117570026_1944988813_a.jpg?_nc_ht=instagram.fadd1-1.fna.fbcdn.net&_nc_ohc=6zVEF7PrIwcAX_x7UQ6&oh=79f8004d8b72cc242a02a703a9304a27&oe=5FAB9F39",
      "profile_pic_url_hd": "https://instagram.fadd1-1.fna.fbcdn.net/v/t51.2885-19/11906086_160969117570026_1944988813_a.jpg?_nc_ht=instagram.fadd1-1.fna.fbcdn.net&_nc_ohc=6zVEF7PrIwcAX_x7UQ6&oh=79f8004d8b72cc242a02a703a9304a27&oe=5FAB9F39",
      "requested_by_viewer": false,
      "username": "ebh14",
      "connected_fb_page": null,
      "edge_felix_video_timeline": {
        "count": 0,
        "page_info": {
          "has_next_page": false,
          "end_cursor": null
        },
        "edges": []
      },
      "edge_owner_to_timeline_media": {
        "count": 9,
        "page_info": {
          "has_next_page": false,
          "end_cursor": null
        },
        "edges": [
          {
            "node": {
              "__typename": "GraphImage",
              "id": "202998178801934666",
              "shortcode": "LRMcShimFK",
              "dimensions": {
                "height": 612,
                "width": 6
              }
            }
          }
        ]
      }
    }
  }
}

在文本中使用以下内容应该可以满足您的需求:

jq '.graphql.user.full_name,.graphql.user.edge_followed_by.count,.graphql.user.followed_by_viewer,.graphql.user.is_business_account,.graphql.user.business_email,.graphql.user.is_verified'