linux - How to take json file output by bash as input
怪我咯
怪我咯 2017-06-19 09:07:30
0
2
855

Script novice, new to bash and zsh, now need to write a script to handle many test accounts in linux.

After using the commandaws get-role...., the output in cmd displays ajsontext, and then I plan to usejqto parse it based on the key Out one of the values, but because of the huge number of accounts being processed, the json text corresponding to these accounts cannot be stored in file form for processing. Is there any way?

The approximate logic is as follows:
The ultimate goal is to get the value of name
name=$(cat (aws get-role....) | jq .Role.Name)But I If I write like this, the system will prompt mezsh: number expected

Is there something wrong with my brackets? Ask God for answers.
If the bracket problem is solved, is this way of writing too long and not beautiful? I am also asking for some guidance from the master, I am very grateful.

怪我咯
怪我咯

走同样的路,发现不同的人生

reply all (2)
迷茫

Try it:

name=$(aws get-role....| jq .Role.Name)
    伊谢尔伦

    The

    catcommand is followed by the file name, and the operation is to output the file content. However,aws get-role....What is output to STDOUT is not the file name but an entire JSON string, so I think it is better to usename=$(aws get-role.... | jq .Role.Name)That’s it.

      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!