Anastasios Lisgaras <tasosnumber...@yahoo.gr> wrote:
> Hello community,
> 
> I have a YAML file for example `resource.yaml`.
> I want to find in this file all the lines ( actually it should be
> only one ), with the following string: "resource_type: apple" and
> immediately after that line add the following lines:
> 
> ```
>    color: red
>    weight: '1 kg'
>    origin: "Country x"
> ```
> 
> The result should be:
> 
> ```
> resource_type:
>    color: red
>    weight: '1 kg'
>    origin: "Country x"
> ```

Just to note that your stated result doesn't appear to match your
stated problem. The word 'apple' is missing.

> Any advice using awk, sed or something else ?

Greg's answer is probably as good as any (I haven't tested it myself)
FWIW, the YAML spec seems to be at https://yaml.org/spec/1.2.2/ though
it's not needed.

Reply via email to