LiveFire Labs - Online UNIX Training - Company Logo


Online UNIX Training with Hands-on Internet Lab


"Eliminate the expense and inconvenience of classroom training without eliminating the classroom experience."

 


Home
Internet Lab
Console Access
Sample Course

Student Login


LiveFire Labs' UNIX Tip, Trick, or Shell Script of the Week - View


Questions? Call
1.888.843.1637 or send us email

October 6, 2003 - Useful Shell Scripting Variables - Part II - PATH

ksh uses the value stored in PATH to determine where it should look for the commands you want to execute.  A typical definition for PATH may be:

$ print $PATH
/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/X11R6/bin:/usr/games

This variable is referenced when a program without a “/” is entered at the command line, checking each directory from left to right for the program.  Notice that a colon separates each directory in the list.

If you wanted to add another directory to the list, for example /tmp, it could be added using the following command:

$ PATH=${PATH}:/tmp
$ print $PATH
/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/X11R6/bin:/usr/games:/tmp 

Now, when ksh looks for a command it will also look in /tmp after it has checked the directories that precede it in the list.

If your shell script runs commands that are stored in directories other than those typically found in PATH, you will need to append to or completely replace what is stored in PATH from within the script.


Learn more...
  

If you are new to the UNIX or Linux operating system and would like to learn more, you may want to consider registering for LiveFire Labs' UNIX and Linux Operating System Fundamentals online training course.

If you already have a solid grasp of the fundamentals but would like to learn more about the Korn shell and basic and advanced shell scripting, taking our Korn Shell Scripting course will be beneficial to you.

Our innovative hands-on training model allows you to learn UNIX by completing hands-on exercises on real servers in our Internet Lab.


More Tips...

· 
Popular UNIX Tips from the Past

spacer Box Border
 

Receive the UNIX Tip, Trick, or Shell Script of the Week by Email


First Name:


Email Address:






   1.888.843.1637

Home - Contact us - Company info - Privacy Statement   

 
©2002-2003 LiveFire Labs.  All rights reserved.
Linux® is a registered trademark of Linus Torvalds, author and developer of this public domain operating system.
UNIX® is a registered trademark of The Open Group in the United States and other countries.