oreilly.comSafari Books Online.Conferences.


AddThis Social Bookmark Button

An Introduction to Tiger Terminal, Part 4
Pages: 1, 2, 3, 4, 5

In part one, we created a file called .bash_profile in our home directory that contained a set of aliases for the cp, rm, and mv commands. This file is actually a shell script file: it contains three commands that run in sequence when the .bash_profile file is read. This file turns out to be exactly where we want to set our new PATH environment variable! Open a new Terminal window and type in ls -a to show a listing of all files, including the hidden files indicated by the period in front of their names, and you'll see your .bash_profile file:

Figure 3. .bash_profile

You'll open .bash_profile using nano and add the path to the scripts folder in the system environment using the export command (if you didn't follow along in part one and create this file, you'll do so now):

Figure 4. Add PATH variable

Remember that to write to this file and save it, you will need to use the keystrokes ^O (WriteOut) and then ^X (Exit). Back at the Terminal, activate the changes by typing:

norburym15:~ norburym$ source .bash_profile

If you run the echo $PATH command again, you'll see this:

Figure 5. New PATH details

Now, we're ready! Let's get started!

First Shell Script

Let's create a shell script to see who the users are on my machine:

1. Open a new Terminal window.
2. cd to your new scripts directory:

Figure 6. cd to scripts

3. Create a new shell script by calling nano and naming your new script

Figure 7. nano

4. When you hit the Return key, nano will open a new file called

Figure 8.

5. Type in the following:

Figure 9. Contents of

6. Then save the file (^O) and exit (^X). Take a look in your scripts folder and you'll see your newly created first shell script!

Figure 10. First shell script

Pages: 1, 2, 3, 4, 5

Next Pagearrow