Using sed to insert file content

In order to insert text before a pattern, you need to swap the pattern space into the hold space before reading in the file. For example:

sed "/pattern/ {
         h
         r $scriptPath/adapters/default/permissions.xml
         g
         N
     }" "$manifestFile"

Leave a Comment