Determine path of the executing script

前端 未结 28 3120
再見小時候
再見小時候 2020-11-22 08:01

I have a script called foo.R that includes another script other.R, which is in the same directory:

#!/usr/bin/env Rscript
message(\         


        
28条回答
  •  旧巷少年郎
    2020-11-22 08:23

    You can wrap the r script in a bash script and retrieve the script's path as a bash variable like so:

    #!/bin/bash
         # [environment variables can be set here]
         path_to_script=$(dirname $0)
    
         R --slave<

提交回复
热议问题