shebang line not working in R script

前端 未结 2 1861
梦如初夏
梦如初夏 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.

    0 讨论(0)
  • 2021-02-13 18:51

    Make the file executable.

    chmod 755 shebang.r
    
    0 讨论(0)
提交回复
热议问题