Running Your Scripts Without a Pathname

If you use your script frequently, there are ways to invoke it by just typing the script name, without having to cd to its directory or enter a full pathname. To run a script without having to enter a pathname, the directory that contains the script must be listed in your PATH variable. You can either add the directory of the script to PATH or move the script to a directory that is already in PATH.

Continuing the example from the previous section, assume that your script viemp is in the directory /usr/fred/bin. You can add /usr/fred/bin to PATH like this:

PATH=$PATH:/usr/fred/bin

Having done this, you can invoke viemp like this:

viemp

You don’t have to be in that directory or enter a pathname to run this ...

Get Practical UNIX now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.