Para criar um JSON adequado na lista de endereços IP gerados por somecommand
, use jq
:
somecommand | jq -Rs '{
Comment: "Update record to reflect new IP address of home router",
Changes: [ {
Action: "UPSERT",
ResourceRecordSet: {
Name: "testing.mak.online.",
Type: "A",
TTL: 60,
ResourceRecords: split("\n")|.[0:-1]|map({Value:.})
} } ] }'
Isso resulta em
{
"Comment": "Update record to reflect new IP address of home router",
"Changes": [
{
"Action": "UPSERT",
"ResourceRecordSet": {
"Name": "testing.mak.online.",
"Type": "A",
"TTL": 60,
"ResourceRecords": [
{
"Value": "192.168.1.84"
},
{
"Value": "192.168.1.85"
}
]
}
}
]
}
dado que somecommand
outputs
192.168.1.84
192.168.1.85