@kc1di :-
Good one, Dave.
The way I taught myself Bash scripting may not work for anyone else, but I started off by automating very simple functions - "Hello World" was one of the first, it's true.
I did a lot of research. I studied tutorials on many of the Linux blogs. Some of these had examples for various things, with step-by-step instructions. I visited a LOT of online manpages, to get a better idea of how various functions should be implemented, along with their available options and what these did.
I quite unashamedly admit that I also extracted packages created by many other Puppians, to study how they, too, went about things.....and I spent hour after hour just trying stuff out in the terminal. This is probably the most salient point; practice, practice, and MORE practice.
As you get more confidence you start to string things together, so that conditions in one place will lead to actions in another. This is probably the basis of all programming; you know what you want to do and, little by little, with lots of experimentation, you discover the most efficient/effective ways of scripting to achieve your desired outcome.
Bash scripting is an ongoing process; it's always interesting to see what CAN be done, and you're always learning. In my case, many functions get their own dedicated scripts.....following the general Linux/Unix philosophy; do ONE thing, but do it as well as possible. Then a main, or "master" script, calls all these scripts as & when required and strings everything together to deliver the results I'm after. Perhaps not a very
good technique.....but it helps me to keep my scripts simple. The more complex your scripts grow, the harder troubleshooting becomes as & when things inevitably misbehave.
(I'm not after making a career outta this stuff.....those days are behind me now, thank God. For me, this is a hobby; it's something I enjoy, and hails all the way back to the very first simple "Hangman" program I wrote on a Commodore 64 in 1983!)
~~~~~~~~~~~~~~~~~~~~~
Scripting is like learning any language; different programming languages have their own distinct nuances, and implement things in different ways. But you can probably achieve the same outcome in a dozen or more ways; you find what works for you.....and you "play" with it!
It's good fun. There IS no "right" or "wrong" way to script; as stated above, over time - and as your confidence grows - you will sooner or later develop techniques that work for YOU. And never be afraid to try new things; it's quite surprising - and you WILL discover this - how often the same snippets of code show up in different places.
Just play around; experiment.....and above all, ENJOY. Learn at your own pace; it's not a competition, to see who can learn the fastest. It doesn't work like that.
Results are what count....
Mike.
