我试过
for line in readlines(`cmd`)
其中cmd是外部命令的名称,但是等待所有输出完成以开始读取。
我想要的是类似于Python的
subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
for line in p.stdout
答案 0 :(得分:4)
您可以这样做:
julia> open(`ls`) do io
while !eof(io)
line = readline(io)
@show line
end
end
line = "bar"
line = "baz.txt"
line = "foo.sh"