Programming and Scripting :: $PATHTOSELF



Again again.. One simple Q. Bash scripting of course.  :;):

How to get path to currently running bash script?
Is there a predefined variable for it?

I need to make my script to run itself in some cases.

The built-in bash variable is $0
This returns the full path to the script, or to a link if a link was used to call the script.  In either case, though, it should work for most purposes.  The only place where I've seen a link be a problem is if the script has to cd into the directory containing the script.

Ah. Of course.
I actually knew that, but never thought it as a path. =D
I just thought it as a script's name/the first command in the line.

Thanks anyways. :D


original here.