Say I put an executable tcsh file in /path/to/my_script.csh
and my current directory is anywhere, for example I'm in /path
So I type to/my_script.csh
I want to have a line in my_script.csh that will return "/path/to/my_script.csh" - like ruby's
__FILE__
If you want to ensure the same result (full path and script name) try something like this:
Then you can call it as foo.sh, ./foo.sh, some/lower/dir/foo.sh and still get the same result no matter how it is called.
If you want an absolute path then this should help you out:
Source: http://tipsarea.com/2013/04/11/how-to-get-the-script-path-name-in-cshtcsh/
In c shell, try like this: