If it can help, here’s my process for writing good shell scripts (and not “God Shrek scripts,” as my autocorrect wanted me to tell you):
1. Type a few simple commands until something works;
2. Make them a bit more complicated to reduce the amount of manual work;
3. Copy the result from the shell history and make a quick and dirty script;
4. Refactor it to make it easier to read;
5. Run ShellCheck to make it more correct;
6. Bin it and rewrite the whole thing in Go.