sed: replace multiline

Viewed 1409

I'm trying to do a multiline replace using sed on OSX (zsh). My input file (Unity Asset file) looks like this:

...
displaySetting: 0
 applicationIdentifier:
  Android: com.appid.name
  Standalone: com.appid.name
  Tizen: com.appid.name
  iOS: com.appid.name
  tvOS: com.appid.name
buildNumber:
 iOS: 190
someOtherID: 190
moreIDsOverHere: 978987
...

I want to replace

buildNumber:
 iOS: 190

with

buildNumber:
 iOS: myBuildNumber

using the following command:

sed "N;s/^\\(.*buildNumber:.*.*$^.*iOS: \\)[0-9]*.*$/\\1myBuildNumber/;P;D" file.asset

This works except for it also removes the last line. I suspect this had something to do with my use of the pattern buffer, but I don't seem to be able to find a solution.

Help would be much appreciated!

2 Answers
Related