-1

My issue is that as I share my project on GitHub I wish to enclose a run.command file containing the terminal commands. The .R files in the same root folder as the .command file.

Rscript 01-xy.R
Rscript 02-yz.R

But how can I set that the codes are evaluated in the current folder. Looking st like cd (folder of this file). Thanks in advance, M

  • Does ["How do I get the directory where a Bash script is located from within the script itself?"](https://stackoverflow.com/questions/59895/how-do-i-get-the-directory-where-a-bash-script-is-located-from-within-the-script) answer your question? Also, see [BashFAQ #28: "How do I determine the location of my script? I want to read some config files from the same place."](http://mywiki.wooledge.org/BashFAQ/028) – Gordon Davisson Dec 02 '22 at 02:54

1 Answers1

0

Solved

cd $( dirname -- "$0"; )