Enabling a script to run in multiple paths

I have a script that i need to run from different paths.

for example
mypc/path1/path2/,
mypc/path1/path2/path3/, and
mypc/path1/path2/path3/path4

How do i set up that script so that it can execute in any
of the above paths or how can i make it run on any path on my computer??

Some possibilities:

  • make an alias in your .profile
  • place the script in a directory that's set in the PATH variable
  • add the path of your script in the PATH variable

Regards

To elaborate, there is a line in your .profile that says PATH=

The PATH defined has several paths listed, separated by colons. One of the PATHs is probably . by itself. A . by itself means 'current directory'.

When you attempt to execute a command/script, the OS searches each of the paths listed in PATH to find the command/script you specified.

Therefore, you have to put your script in one of the paths specified, or add the path where your script lives to the PATH variable.

On a side note, the command which [command] returns the path of the [command] specified.

Thanx for the help but am a bit new in unix. Where do i find
that file for the user profiles that i need to edit the PATH variable.

Thanx for the help but am a bit new in unix. Where do i find
that file for the user profiles that i need to edit the PATH variable.

the . profile file usually resides in user home directory.

cd $HOME
ls -lart ---> list the files whose name starts with "." (hidden files)