如何从Julia REPL运行shell命令?



在Julia REPL中,我想运行一些终端命令,但不一定想通过管道或围绕系统调用的其他语法来执行这些命令。是否有一种更本机的方式从REPL运行终端命令?

Julia的REPL具有所谓的Shell模式。您可以通过在终端中输入;来访问Shell模式,这将导致:

_
_       _ _(_)_     |  Documentation: https://docs.julialang.org
(_)     | (_) (_)    |
_ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` |  |
| | |_| | | | (_| |  |  Version 1.6.0 (2021-03-24)
_/ |__'_|_|_|__'_|  |  Official https://julialang.org/ release
|__/                   |
shell> 

你可以运行如下命令:

shell> pwd
/Users/my_username
shell> 

阅读更多关于Shell模式的信息:https://docs.julialang.org/en/v1/stdlib/REPL/#man-shell-mode

最新更新