Script novice, new to bash and zsh, now need to write a script to handle many test accounts in linux.
After using the command aws get-role....
, the output in cmd displays a json
text, and then I plan to use jq
to 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 namename=$(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.
伊谢尔伦2017-06-19 09:09:30
The
cat
command 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 use name=$(aws get-role.... | jq .Role.Name)
That’s it.