英文:
How to make Julia file execute like a sh file?
问题
我有一个名为hello.jl的Julia脚本,内容如下:
print("Hello world")
如何使其像.sh文件一样在双击时执行?
我使用的是Linux Mint 21,并且已经安装了Julia和bash环境。
英文:
I have a julia script hello.jl with following content:
print("Hello world")
How to make it execute like a .sh file i.e. on double click on it?
I am using Linux Mint 21, and have julia installed the bash environment.
答案1
得分: 1
如@Alexander Morley所说(通过@August)这里:
> 如果你想直接从终端执行它,可以在脚本开头添加一个shebang,例如[创建一个名为“hello”的文件,并将以下内容添加为它的内容:
>
>
> #!/usr/bin/env julia
>
> println("hello world")
>
> [然后通过在所在文件夹中运行以下命令使其可执行]
>
> [user@computer]$ chmod +x hello
>
> 然后它应该按预期运行
>
> ./hello
英文:
As @Alexander Morley said (via @August) here:
> If you want to execute it directly from the terminal you can add a
> shebang to the beginning of your script e.g. [create a file called "hello" with the following as it's contents:
>
>
> #!/usr/bin/env julia
>
> println("hello world")
>
> [then make it executable by running the following in the folder it is within]
>
> [user@computer]$ chmod +x hello
>
> then it should run as expected
>
> ./hello
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论