How to write a script that removes a certain set of apps everytime you flash an update file? I run a LineageOS device with MicroG, but since the default messaging app is not able to be disabled I need to remove it everytime I flash an update file. This is becoming more and more tedious as more apps I need to remove on update increase. 

How do you write a script that removes these apps whenever you flash so the removal changes persists? Something like addon.d but that is for backing up apps.

Edit : Both answers are correct, the one I posted and the one by Death Mask Salesman. I accepted the one by Death Mask Salesman because it is relevant to the question, however the one I posted solved my problem.
I tried pm disable &lt;app&gt;, pm hide &lt;app&gt;, and pm block &lt;app&gt; – but all of them spew out error messages. But when I tried pm disable-user &lt;app&gt; it works! And the changes persists after reflashing, so that's great! I don't need to write a script after all!