GUIs are great for when you're new to a bit of software as you can see the various options and get a feel for the possibilities. CLIs are nearly always more flexible once you've read the man page, but is a steeper learning path.
Automation/scripting is when CLIs really come into their own as otherwise you end up becoming a GUI click monkey. The best is when there's both a GUI and CLI (as long as they work the same way).
I wonder how good CLIs could have been if a fraction of the resources that have gone into GUIs had gone into making CLIs more user friendly. A sequence of words is a pretty natural way of conveying what you want done.
I often get my way through unknown CLI commands by just typing TAB and selecting the option that sounds like what I want. Works, most of the time, I don't think that is really an issue. For most CLI programs you also have a reference/cheat sheet, examples and an interactive hypertext systems of tutorials available.
Along with the "-h,--help" options, an option to show common usage examples would be useful. I find it much easier to learn from an example as you can modify and build upon it. Otherwise, it's a case of skimming through the man page and then switching back and forth between the man page and the command that I'm writing. (This is most common with tools that I don't use all the time, yet have expert features such as "ffmpeg")
> an option to show common usage examples would be useful.
That's what the man page is supposed to be (and most do contain example) and why GNU wanted to split it into info (tutorials and exhausting documentation) and man (reference and examples).
Why do you serialize and then deserialize the list of files? Even if you do disable the splitting on reparsing the list, why don't you just do this:
find . -type f -name '*.mp3' -exec some command {} ';'
That sounds just unnecessary and bug prune. Unless you target some odd platform where find doesn't support '-exec', but it is even in POSIX. I think due to your use of process substitution, your code has a higher chance of being unportable, so why do you want to complicate your code?
Stuff like that is why I personally prefer the man pages to random websites.
Honestly for something as complex as a shell (which describes both a language, an editor, and an implementation) the man page is surprisingly short. (6418 lines for me) I have just found the section on process substitution in <1min, without even using the search, just by reading. I looked it up, because I didn't knew the name of that syntax, so I needed to actually look for what I wanted and I do not use the man page of bash often.
It's to deal with problematic filenames (e.g. containing a newline) and enables setting of variables within the current process. Putting multiple commands into the "-exec" of find is possible, but looks horrible. To be fair, my example didn't use multiple commands, so your version is okay for simple processing.
Don't get me wrong, the BASH man page is great, it's just that I prefer to work with examples.
Yep, you can chain multiple commands with find's "-exec", but I'm not a fan of it myself. I suspect setting variables in the current process is trickier though.
(Very minor nitpick, it should be 'a\nb.mp3' to be included, but that does work fine)
Incidentally, ShellCheck isn't happy with that although I don't follow their reasoning:
find . -type f -name '*.mp3' -exec bash -c "
^-- SC2156 (warning): Injecting filenames is fragile and insecure. Use parameters.
I see, but now you are essentially operating on multiple files, at once, so the serialization makes some sense. Although for just this, I wouldn't write the operation in bash at all:
find . -type f -name '*.mp3' | wc -l
Honestly I don't really view the shell / filesystem interface as a security boundary. I use the shell mainly for (automation of) interactive use, so any screwup due to e.g. quoting issues is my own fault, maybe even of using stupid filenames. Shell is a great language to connect streams of different programs into each other, not so much for doing any work. If I do that, I would reach for C.
The serialisation is just to work around the fact that filenames can have any character except for \0 which is why the "-print0" is used. It doesn't by itself allow for concurrent processing.
You're right about just using "wc -l", but I was just trying to demonstrate how you can set variables. A real use would be doing more than just counting files as your example would likely be quicker (assuming that calling an external programme is quicker than running a naive loop in BASH).
I am guilty of using BASH for stuff that most people would use a different language for - I just find that for system admin work that BASH is just at the right level of abstraction for me and is ubiquitous.
Many GUI designers these days don't like discoverability and don't think it's important. They prefer to hide everything behind "gestures" that you just have to know somehow.
Automation/scripting is when CLIs really come into their own as otherwise you end up becoming a GUI click monkey. The best is when there's both a GUI and CLI (as long as they work the same way).