[LBo] Running shell script

Chris F.A. Johnson cfajohnson at teksavvy.com
Fri Jan 5 22:04:28 CET 2007


On Fri, 5 Jan 2007, Rafi Gabzu wrote:

> How do I add it permanently ?
> In the $HOME/.bashrc  I do not see the PATH variable, I see it in the
> /etc/profile (there it configure PATH for root and for user)

     Just add the line to the end of your .bashrc.

     If you want to make sure that it isn't already in your PATH (not
     that it really matters), use:

case :$PATH: in
      *:$HOME/bin:*) ;;           ## Already there; do nothing
      *) PATH=$PATH:$HOME/bin ;;  ## Not there, so add it
esac

> On 1/5/07, Chris F.A. Johnson <cfajohnson at teksavvy.com> wrote:
>>
>>  On Fri, 5 Jan 2007, Rafi Gabzu wrote:
>> 
>> >  I probably missed something  ,  why  in order  to  run  shell  script  I
>> >  need to  use the dot and back slash :(e.g  ./hello.sh ) ? why not just
>>  to
>> >  run it ...?
>>
>>       You can either use ./scriptname (that's a slash, not a backslash),
>>       or you can put the script in a directory that is included in your
>>       PATH. I recommend that you do the latter.
>>
>>       The shell looks in the directories in your PATH variable (a
>>       colon-separated list of directories), and the current directory is
>>       not usually included (nor should it be).
>>
>>       I recommend that you create your own directory (e.g., $HOME/bin)
>>       and add it to your PATH in $HOME/.bashrc:
>>
>>  PATH=$PATH:$HOME/bin

-- 
    Chris F.A. Johnson                      <http://cfaj.freeshell.org>
    ===================================================================
    Author:
    Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)


More information about the QnA mailing list