I do wish to modify a Mac OS X sandbox file via a one-line (copy and paste) command, by inserting a new line — containing a regex — after a line that contains a specific string (also being a regex pattern).
The file to edit requires root rights and is located at
Both search and append lines contain loads of usually to be escaped characters because these are regex-es and containing paths.
Search for line containing
Note: the string is preceded with tabs in one case.
Insert this line before the match
Note: this to be inserted new-line-string should be prepended with one tab (
My failing try
sudo sed -i '' -e $'/(regex #"\^\/private\/var\/clamav\/")/a \t(regex #"\^\/System\/Library\/PrivateFrameworks\/TrustEvaluationAgent\.framework\/Versions\/A\/TrustEvaluationAgent\\\$")' /usr/share/sandbox/clamd.sb sed: 1: "/(regex #"\^\/private\/ ...": command a expects \ followed by text
How to fix the above
supply a better readable and working alternative that can be used to copy from a website and paste into the Mac OS X terminal (bash) to extend this sandbox configuration file?