Using sed to replace multi line strings is notoriously difficult
I can suggest to use perl. This prints out the modified file.
perl -0777 -pe 's/com.apple.ApplePay = {\s*\n\s*enabled\ =\ 1;/com.apple.ApplePay = {\nenabled\ =\ 0;/g' file1 2> /dev/null
I have not taken into consideration the white spaces in the output. Depending on the indentation of your file you can set spaces before enabled\ =\ 0
The input file is called file1
in my example.
Input
$ cat file1
12345678 = {
CreatedOnToolsVersion = *.*.*;
DevelopmentTeam = *;
LastSwiftMigration = *;
ProvisioningStyle = Manual;
SystemCapabilities = {
com.apple.ApplePay = {
enabled = 1;
};
com.apple.SafariKeychain = {
enabled = 0; };
com.apple.SafariKeychain = {
enabled = 0;
};
};`
};
};
Output
$ perl -0777 -pe 's/com.apple.ApplePay = {\s*\n\s*enabled\ =\ 1;/com.apple.ApplePay = {\nenabled\ =\ 0;/g' file1 2> /dev/null
12345678 = {
CreatedOnToolsVersion = *.*.*;
DevelopmentTeam = *;
LastSwiftMigration = *;
ProvisioningStyle = Manual;
SystemCapabilities = {
com.apple.ApplePay = {
enabled = 0;
};
com.apple.SafariKeychain = {
enabled = 0; };
com.apple.SafariKeychain = {
enabled = 0;
};
};`
};
};
For in place replacement use
perl -0777 -pi -e 's/com.apple.ApplePay = {\s*\n\s*enabled\ =\ 1;/com.apple.ApplePay = {\nenabled\ =\ 0;/g' file1 2> /dev/null