It is nice you post code for other to benefit, but please, as all code show here on the forums, it should be posted using the Preformatted text feature (the button: </>).
It not only will format fixed font and all tabs, etc. as it was in your original scripting code, but look careful and you will see it changed your " characters into “ and ”. So anybody that would copy this will wonder why bash interprets this as rubbish.
3 back-quotes (backtick) on a blank line above the code and 3 after on a blank line
On a mobile device, the editor toolbar is only partially shown (for me, anyway) - you tap the gear icon to show remaining options. Like now, I’m using the Brave browser on my Android phone, so I have to manually tap the backquotes or use gear icon
.