Looks like there is an error on that code then, it works if I run it slightly modified on the command line but not from php, seems to be various bits escaping that \n that trip it up, it needs to be \n to sed, but it's getting escaped to \n when executed.
Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.