【问题标题】:How can Julia shell commands handle pipes?Julia shell 命令如何处理管道?
【发布时间】:2019-02-09 03:04:49
【问题描述】:

在 Julia 1.0 REPL 中使用 shell 命令。 ; ls 工作正常,;sort foo 也是如此

但是,我在管道方面没有成功,; ls| sort

shell> ls | sort ls: sort: No such file or directory ls: |: No such file or directory

有什么解决方法吗?我在 macos 上运行 bash。

【问题讨论】:

    标签: shell julia read-eval-print-loop


    【解决方案1】:

    根据docs,需要使用runpipeline

    尝试运行:

    run(pipeline(`ls`, `sort`))
    

    【讨论】:

    • run(`ls` |> `sort`)
    • 我正在使用 1.0 macos @user1934428 错误:MethodError:Cmd 类型的对象不可调用 Stacktrace:[1] |>(::Cmd, ::Cmd) at ./operators.jl: 813 [2] *范围无:0`
    • @niczky12 run(pipeline...))。可以,但是感觉和“;”不一样
    • 我知道。但这是我能找到的唯一解决方法。你试过用 slack 提问吗?