LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-16-2010, 05:24 AM   #1
kickarzt
LQ Newbie
 
Registered: Feb 2010
Posts: 18

Rep: Reputation: 0
How to run a bashscript no matter what directory u stand in?


How to run a bashscript no matter where u stand in the directory?
 
Old 03-16-2010, 05:29 AM   #2
linuxlover.chaitanya
Senior Member
 
Registered: Apr 2008
Location: Gurgaon, India
Distribution: Cent OS 6/7
Posts: 4,631

Rep: Reputation: Disabled
By using a complete absolute path to the script?
 
Old 03-16-2010, 05:33 AM   #3
vinaytp
Member
 
Registered: Apr 2009
Location: Bengaluru, India
Distribution: RHEL 5.4, 6.0, Ubuntu 10.04
Posts: 707

Rep: Reputation: 55
Quote:
Originally Posted by kickarzt View Post
How to run a bashscript no matter where u stand in the directory?
May be by keeping the script in /usr/bin/ directory, Provided /usr/bin path added in PATH environment variable and you have root privileges.


OR

Add path of the directory where the scripts exists to PATH environment variable

Better set PATH variable in ~/.bash_profile.
Code:
$PATH=$PATH:/usr/bin:/your/directory/where/script/present
export $PATH
Now execute

Code:
source ~/.bash_profile

Last edited by vinaytp; 03-16-2010 at 05:48 AM.
 
Old 03-16-2010, 06:03 AM   #4
kickarzt
LQ Newbie
 
Registered: Feb 2010
Posts: 18

Original Poster
Rep: Reputation: 0
Thank for the answers!
 
Old 03-16-2010, 06:53 AM   #5
jamescondron
Member
 
Registered: Jul 2007
Location: Scunthorpe, UK
Distribution: Ubuntu 8.10; Gentoo; Debian Lenny
Posts: 961

Rep: Reputation: 70
Personally, because playing with $PATH can lead to some behaviour you don't always want, I set subroutines in my .bashrc; colour paging (Which grabbed from some website, forgotten the name, but I dare say the author of this solution wont mind)

Code:
# syntax highlighting pager
colpage () {
/usr/share/vim/vim71/macros/less.sh "$*"
}
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Does Linux stand a chance now that Windows 7 will run on netbooks? LXer Syndicated Linux News 0 01-17-2009 06:50 AM
LXer: Does Linux stand a chance now that Wndows 7 will run on netbooks? LXer Syndicated Linux News 0 01-16-2009 10:10 PM
Using wine to run games, does it matter how I install theme? Nsis Linux - Newbie 11 09-11-2008 05:56 PM
What do the directory names stand for jken Linux - General 4 08-26-2004 07:26 AM
What does the directory /etc/ stand for? nutshell Linux - General 2 03-01-2002 10:41 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration