如何将源文件中的文本附加到目标文件中的EOF之前的目标文件中

问题描述 投票:0回答:1

我有2个文件。文件1:source.sh文件2:destination.sh

我想将文件1的内容插入文件2。但是我不想在文件末尾插入内容。文件2的最后一行是“}”

我想将文件1的内容插入“}”之前的文件2中

我的确切代码:

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}"

我的目的地.sh

{
    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}"
    }

我需要在}之前将source.sh插入destination.sh中

因为它已经投入生产,所以我不想硬编码任何数字来定义EOF ...任何帮助表示赞赏

我有2个文件。文件1:source.sh文件2:destination.sh我想将文件1的内容插入文件2。但是我不想在文件末尾插入内容。文件2的最后一行...

linux bash shell copy append
1个回答
0
投票

您可以尝试使用ed(1)

© www.soinside.com 2019 - 2024. All rights reserved.