Before you start writing your shell scripts, you should always ask yourself whether a shell script really is the best solution. In many cases, other solutions are available. Instead of using the Bash shell as a scripting language, you can use Perl, for example, or you can write a complete program in the C programming language. Each of these solutions has its advantages and disadvantages.
The most important advantage of using Bash as your scripting language is that Bash scripts are relatively easy to understand and to make. Another advantage is that you don't have to compile them before you can start using them. Shell scripts are also easier to debug than other languages. The only piece you need on the computer where you are going to run your shell script is the shell for which the script is written. In addition, since the Bash shell is omnipresent, performing tasks with your script on other Linux computers shouldn't be a problem.
The most important disadvantage of using Bash as the solution to create your script in is that Bash is relatively slow. This is because the shell always has to interpret the commands that are in the shell. By contrast, a C program is compiled code, optimized to execute its work on the hardware of your computer directly; therefore, C is much faster.
Was this article helpful?