Я хочу создать массив JSON для шагов emr.Я создал массив для одной строки JSON.Вот мой код bash -
export source="s3a://sourcebucket"
export destination="s3a://destinationbucket"
EMR_DISTCP_STEPS=$( jq -n \
--arg source "$source" \
--arg destination "$destination" \
'{
"Name":"S3DistCp step",
"HadoopJarStep": {
"Args":["s3-dist-cp","--s3Endpoint=s3.amazonaws.com", "'"--src=${sourcepath}"'" ,"'"--dest=${destinationpath}"'"],
"Jar":"command-runner.jar"
},
"ActionOnFailure":"CONTINUE"
}' )
output
echo $EMR_DISTCP_STEPS
[{ "Name": "S3DistCp step", "HadoopJarStep": { "Args": [ "s3-dist-cp", "--s3Endpoint=s3.amazonaws.com", "--src=s3a://sourcebucket", "--dest=s3a://destinationbucket" ], "Jar": "command-runner.jar" }, "ActionOnFailure": "CONTINUE" }]
Теперь я хочу создать массив JSON с несколькими исходными и целевыми выходными данными
[{ "Name": "S3DistCp step", "HadoopJarStep": { "Args": [ "s3-dist-cp", "--s3Endpoint=s3.amazonaws.com", "--src=s3a://sourcebucket1", "--dest=s3a://destinationbucket1" ], "Jar": "command-runner.jar" }, "ActionOnFailure": "CONTINUE" },
{ "Name": "S3DistCp step", "HadoopJarStep": { "Args": [ "s3-dist-cp", "--s3Endpoint=s3.amazonaws.com", "--src=s3a://sourcebucket2", "--dest=s3a://destinationbucket2" ], "Jar": "command-runner.jar" }, "ActionOnFailure": "CONTINUE" },
{ "Name": "S3DistCp step", "HadoopJarStep": { "Args": [ "s3-dist-cp", "--s3Endpoint=s3.amazonaws.com", "--src=s3a://sourcebucket3", "--dest=s3a://destinationbucket3" ], "Jar": "command-runner.jar" }, "ActionOnFailure": "CONTINUE" }]
Как создатьJSON Массив с несколькими источниками и получателями (строка JSON) в Bash?