NokiMo
The Linux Cast
The Linux Cast

patreon


Bash Scripting Snobbery

I am not good at bash scripting. I'm learning, but it's a long process. I've been watching some Youtube videos on the subject, and found a lot of tutorials that are just seriously off putting. 

The one thing I've pretty much learned about programing of any sort is that there are usually two or more ways of doing something. The syntax might be rigid, but there are usually a lot of ways of actually getting something done. 

printf and echo in bash come to mind as one example.

But it seems that some people who are known as 'premier' bash scripting youtubers, are very rigid on the right way of doing things. It makes it harder to learn because it isn't as if they all agree on what the right way actually is. 

Should there be proper spaces between case statements, if statements and so on? One Youtuber does it one way, and bemoans anyone who does it the other. It's dumb. 

So my lesson as I've been doing more scripting is that there is more than one way to do it, and there isn't really a 'right' way as long as the damn script works in the end. Screw it if it doesn't fit in with the 'way it is supposed to be done.'

Comments

My point was that you could technically accomplish the same thing with either of them, and there are a ton of things like that in bash. I mean cat and less do variations on the same thing. They do different things too, of course, but the idea is still there.

Matthew Weber

Echo ends in a new line, whereas printf is basically bare-bones. Printf is much more extensible, and if you keep fiddling, you will probably run into the difference naturally. Definitely a lot of stuff to tinker with, you're 100% with this one, I encourage you to mess around as much as possible.

Zach Enseleit


Related Creators