Advantages of Shell Scripting

There are many reasons we write shell scripts. However, they are written mainly:
- To avoid repetitive work and automation: Suppose there is a task that you need to perform daily by executing the same commands on Linux everyday. You can automate the process by storing these commands in a file and then run it as a shell script. As an example, you may want to check the price of a particular stock daily and want to trigger an SMS if the price fulfills certain conditions.
- Routine backups can be done using shell scripts: One of the easiest ways to take backup is through the use of shell scripts. For example, we can use a shell script to back up particular directories.
- For system monitoring: Monitoring can be performed by using shell scripts in our system. For example, we can monitor the CPU utilisation on our Linux system through a shell script, which will trigger an email to a specific email ID when the system reaches a certain threshold (say, 70 % utilisation). Other examples include sending email upon the detection of hardware error, monitoring the process running on our system after every hour.
- To add new functionality to the shell: We can use shell scripts to perform various operations in our system. It adds more functionality to the shell as it can be used multiple times without writing the same commands all over again, thus reducing manual effort. As an example, if you want to know the number of users that are logged in to the system and what are the tasks that they are performing, then you can do so using shell script and using it whenever required.