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 ajson
text, and then I plan to usejq
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.
Try it:
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 usename=$(aws get-role.... | jq .Role.Name)
That’s it.