Shell scripts are text files containing commands to be executed.
Shell scripts are useful for:
- Automating commonly used commands
- Performing system administration and troubleshooting
- Creating simple applications
- Manipulation of text or files.
A shell script is simply a text file containing commands. Scripts are useful for automating processes that you perform repeatedly at the command line. For example suppose every morning when you log in, you perform the following operations:
- Check the system dare.
- Look at the calendar for thr current month.
- Check your email.
- Display the list of logged in users.
Instead of entering the commands to perform steps 1-4 individually, you could create a shell script containing those commands. Every morning you could enter just one command to perform all these steps. In addition the key benefit of using Linux is using the powerful, yet simple commands. These commands may be put together in a script to perform complex operations or automate procedures such as adding batches of users.
Linux users involved with system administration and troubleshooting often work with shell scripts. Many of these are created during the installation of the operating system. Consider the script /etc/profile. This file is the system- wide user login script which runs whenever a user logs into the system. System administrators and troubleshooters will consider operations performed in this script when troubleshooting user login problems.
Programmers often create simple versions of programs using scripts during the initial phases of a programming project. This is called application prototyping. Once they and the program’s users are happy with the main functionality of the program, the programmer will then create the full-featured program in a programming language such as C.