The basic shell script
Shell scripts
A shell script has a myriad of purposes on a Linux box. You can have them run at bootup so that they initiate commands or processes without you having to manually start them. They can be used to run a sequence of events. They can manipulate files, execute a program, print text, and walk your dog. Well, the last part is true if your dog is a robot. However, we're getting ahead of ourselves.
It's time for our friend Major Tom. We've missed him, but let's bring him back to earth for a moment with a very simple shell script.
How to do it...
Perform the following steps:
- Create a new directory as follows:
$ mkdir bin
- Then, let's move to the new directory using the
cd
command:$ cd bin
- Now, create a new file that will become our shell script, as shown in the following code:
~/bin$ sudo nano major_tom_bash_script
- At the beginning of the file, it's a requirement to tell the shell the kind of script that we'll run so that it can interpret...