我需要以下命令的输出,即"* master\n remotes/origin/HEAD -> origin/master\n remotes/origin/master\n"
输出以供阅读。
iex(26)> System.cmd "git", ["-C", "/home/vonhabsi/workpad/Cuis/.git","branch","-a"]
{"* master\n remotes/origin/HEAD -> origin/master\n remotes/origin/master\n",
0}
即形式
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master
该System.cmd
文档添加into: IO.stream(:stdio, :line)
到命令
iex(27)> System.cmd "git", ["-C", "/home/vonhabsi/workpad/Cuis/.git","branch","-a"], into: IO.stream(:stdio, :line)
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master
{%IO.Stream{device: :standard_io, line_or_bytes: :line, raw: false}, 0}
iex(28)>
我需要"* master\n remotes/origin/HEAD -> origin/master\n remotes/origin/master\n"
从元组中获取什么函数并将其输出为:
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master
额外的输出 {%IO.Stream{device: :standard_io, line_or_bytes: :line, raw: false}, 0}
是不需要的。简而言之,您如何获取一段带有\n
换行符的原始文本并将其输出为应该打印的内容。
您如何将其保存到文件中?