0

Hi I am new to Linux and shell scripting.
I have made a script 'script1.sh' in a directory : /root/ansh/scripts

I want to invoke this script from any other directory . I understand that for doing this I'll have to set the path of the script in some global variable. But I have no idea as to how to go about it.
Kindly let me know.

2
Contributors
3
Replies
6
Views
11 Years
Discussion Span
Last Post by John A
0

To temporarily add a path, use the following syntax:
PATH=$PATH:/your/path/here
To add it permanantly, you need to edit the .profile file in your home directory, and add your path to the list there (which is also seperated by colons).

0

Thanks for the prompt response.
I am however still not clear as to how to do that .
I am working as the root user.
The name of my script is : find.sh
My shell script is in the folder "root/anshul/scripts"
Now where do I add this path, so that I may execute the script from anywhere in the unix box once I have logged in ?
Kindly elaborate on your previous reply.
Thanks.

To temporarily add a path, use the following syntax:
PATH=$PATH:/your/path/here
To add it permanantly, you need to edit the .profile file in your home directory, and add your path to the list there (which is also seperated by colons).

1

My shell script is in the folder "root/anshul/scripts"

OK... type this:

nano ~/.profile

Add this to the end of the line:

:/root/anshul/scripts/find.sh

Then the script will be accessible from any directory (assuming of course, that you're root).

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.