shebang line not working in R script

前端 未结 2 1863
梦如初夏
梦如初夏 2021-02-13 17:53

I have the following script

#!/usr/bin/Rscript

print (\"shebang works\")

in a file called shebang.r. When I run it from command line using Rsc

2条回答
  •  一向
    一向 (楼主)
    2021-02-13 18:28

    In addition to Sjoerd's answer... Only the directories listed in the environment variable PATH are inspected for commands to run. You need to type ./shebang.r (as opposed to just shebang.r) if the current directory, known as ., is not in your PATH.

    To inspect PATH, type

    echo $PATH
    

    To add . to PATH, type

    export PATH="$PATH:."
    

    You can add this line to your ~/.bashrc to make it happen automatically if you open a new shell.

提交回复
热议问题