Saturday, January 23, 2010

How to run a unix shell script from any directory

To run a script from anywhere inside UNIX directory, you need to include the script absolute directory in the PATH variable. After that without using the pathname we can execute the script successfully.

eg:
In .profile, update PATH=$PATH:/home/sujay/scripts and source the .profile

Script Loc: /home/sujay/scripts/
Script Name; anywhere

sujay@laptop:~$ anywhere
++ pwd
+ echo 'Executed from /home/sujay'
Executed from /home/sujay

No comments: