如何使Julia文件执行类似于sh文件?

huangapple go评论70阅读模式
英文:

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
>
> 然后它应该按预期运行 如何使Julia文件执行类似于sh文件?
>
> ./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 如何使Julia文件执行类似于sh文件?
>
> ./hello

huangapple
  • 本文由 发表于 2023年6月15日 12:34:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/76479138.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定