1

I have a file containing just a certificate and I would like to move this over to a second file and overwrite a line in the file.

certificate format will be:

-----BEGIN CERTIFICATE-----
abc
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
xyz
-----END CERTIFICATE-----

The second file is a yaml file and i want to overwrite Value4 with the certificate

Value1
Value2
Value3
Value4

Output would be

Value1
Value2
Value3
-----BEGIN CERTIFICATE-----
abc
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
xyz
-----END CERTIFICATE-----

Any ideas on how this can be done?. Ideally I dont want to use line numbers because the second file may have new fields added below the certificate in the future.

jstead
  • 11

1 Answers1

1
perl -ne '
  print /value4/ ? <STDIN> : $_;
' yaml < cert

value4 line print the entire stdin else use regular input.