Bash scripts – my opinion

Actually, I use bash quite often – usually for one-liners (scripts which can be written in one line) and less often for more complex work. Why? Have you ever tried to debug more complex script written in bash? Of course, you can use bash debugging like “bash -x” but it is far less complex than e.g. python debugger PDB.

Sometimes I have to fix bugs in scripts which was written by my predecessor who loved bash (and was able to write thousands of lines of bash scripts which includes one script into another) and it is really a headache.

There are a few more reasons why I also prefer Python – for example, “global variables” in bash which is a very dirty method of development and sooner or later you will simply get lost in your code. I do not think that you have to use object-oriented programming all the time even for small things but if you write 2.000 lines of code I would really recommend to use it in spite of I use only procedural programming for smaller code bases (up to 100 lines of code).

The largest problem in system administration I see is aging. Everyone is able to install, develop and script a new machine. The complete different story is to manage it over for five or ten years because after just a year you will forget most things you did when deploying a new machine.

Anyway, you can see my small public bash project here – https://github.com/koss822/misc/tree/master/usb_backup. This is a small bash script I use for backing up my home server to portable USB drive with Btrfs filesystem. It uses snapshots and is a good solution for smaller workloads.