0

In a script which I call with the "source" command under linux I want to determine the directory where the script is located. Assuming there is a script under $HOME/foo/bar/sourceme and i call the script from $HOME with source $HOME/foo/bar/sourceme I would like to extract within the script that it is located under $HOME/foo/bar. I know that it is possible without source by using

set _dir = `dirname $0`
setenv MY_DIR = `cd $_dir ; pwd` 

but this doesn't work when i use a source.

rth
  • 41
  • 2
  • I think this is a dupe of https://stackoverflow.com/questions/59895/get-the-source-directory-of-a-bash-script-from-within-the-script-itself – JosefAssad Dec 20 '19 at 11:39
  • i don't find a example in this question how to get the self when calling it via source, maybe you can point me to it. – rth Dec 20 '19 at 11:54

0 Answers0