Вы можете попробовать, используя ed(1)
cat file1.txt
Выход
xxx_ecmwf_scoring_state_machine_arn = "${aws_sfn_state_machine.xxx_ecmwf_main_state_machine.id}"
xxx_ecmwf_etl_state_machine_arn = "${aws_sfn_state_machine.xxx_ecmwf_etl_state_machine.id}"
xxx_ecmwf_scoring_function_name = "${aws_lambda_function.invoke_xxx_ecmwf_scoring_state_machine_lambda.function_name}"
Второй файл
cat file2.txt
Выход
{
zzz_ecmwf_scoring_state_machine_arn = "${aws_sfn_state_machine.zzz_ecmwf_main_state_machine.id}"
zzz_ecmwf_etl_state_machine_arn = "${aws_sfn_state_machine.zzz_ecmwf_etl_state_machine.id}"
zzz_ecmwf_scoring_function_name = "${aws_lambda_function.invoke_zzz_ecmwf_scoring_state_machine_lambda.function_name}"
ccc_ecmwf_scoring_state_machine_arn = "${aws_sfn_state_machine.ccc_ecmwf_main_state_machine.id}"
ccc_ecmwf_etl_state_machine_arn = "${aws_sfn_state_machine.ccc_ecmwf_etl_state_machine.id}"
ccc_ecmwf_scoring_function_name = "${aws_lambda_function.invoke_ccc_ecmwf_scoring_state_machine_lambda.function_name}"
rrr-ltf_ecmwf_scoring_state_machine_arn = "${aws_sfn_state_machine.rrr-ltf_ecmwf_main_state_machine.id}"
rrr-ltf_ecmwf_etl_state_machine_arn = "${aws_sfn_state_machine.rrr-ltf_ecmwf_etl_state_machine.id}"
rrr-ltf_ecmwf_scoring_function_name = "${aws_lambda_function.invoke_rrr-ltf_ecmwf_scoring_state_machine_lambda.function_name}"
rrr_ecmwf_scoring_state_machine_arn = "${aws_sfn_state_machine.rrr_ecmwf_main_state_machine.id}"
rrr_ecmwf_etl_state_machine_arn = "${aws_sfn_state_machine.rrr_ecmwf_etl_state_machine.id}"
rrr_ecmwf_scoring_function_name = "${aws_lambda_function.invoke_rrr_ecmwf_scoring_state_machine_lambda.function_name}"
}
Код
printf '%s\n' '$,/^}/-1a' "" . '$,/^}/-1r file1.txt' ,p Q | ed -s file2.txt
Выход
{
zzz_ecmwf_scoring_state_machine_arn = "${aws_sfn_state_machine.zzz_ecmwf_main_state_machine.id}"
zzz_ecmwf_etl_state_machine_arn = "${aws_sfn_state_machine.zzz_ecmwf_etl_state_machine.id}"
zzz_ecmwf_scoring_function_name = "${aws_lambda_function.invoke_zzz_ecmwf_scoring_state_machine_lambda.function_name}"
ccc_ecmwf_scoring_state_machine_arn = "${aws_sfn_state_machine.ccc_ecmwf_main_state_machine.id}"
ccc_ecmwf_etl_state_machine_arn = "${aws_sfn_state_machine.ccc_ecmwf_etl_state_machine.id}"
ccc_ecmwf_scoring_function_name = "${aws_lambda_function.invoke_ccc_ecmwf_scoring_state_machine_lambda.function_name}"
rrr-ltf_ecmwf_scoring_state_machine_arn = "${aws_sfn_state_machine.rrr-ltf_ecmwf_main_state_machine.id}"
rrr-ltf_ecmwf_etl_state_machine_arn = "${aws_sfn_state_machine.rrr-ltf_ecmwf_etl_state_machine.id}"
rrr-ltf_ecmwf_scoring_function_name = "${aws_lambda_function.invoke_rrr-ltf_ecmwf_scoring_state_machine_lambda.function_name}"
rrr_ecmwf_scoring_state_machine_arn = "${aws_sfn_state_machine.rrr_ecmwf_main_state_machine.id}"
rrr_ecmwf_etl_state_machine_arn = "${aws_sfn_state_machine.rrr_ecmwf_etl_state_machine.id}"
rrr_ecmwf_scoring_function_name = "${aws_lambda_function.invoke_rrr_ecmwf_scoring_state_machine_lambda.function_name}"
xxx_ecmwf_scoring_state_machine_arn = "${aws_sfn_state_machine.xxx_ecmwf_main_state_machine.id}"
xxx_ecmwf_etl_state_machine_arn = "${aws_sfn_state_machine.xxx_ecmwf_etl_state_machine.id}"
xxx_ecmwf_scoring_function_name = "${aws_lambda_function.invoke_xxx_ecmwf_scoring_state_machine_lambda.function_name}"
}
Чтобы использовать скрипт для ed
cat script.ed
Выход
$,/^}/-1a
.
$,/^}/-1r file1.txt
,p
Q
Теперь вы можете запустить
ed -s file2.txt < script.ed
Замените ,p Q
на w
для редактирования файла in-place
Мое решение работает с файлом Формат, который я опубликовал, вам нужно исправить формат файла в вашем сообщении, если это не так.