【文件属性】:
文件名称:go-shell-pipes:增强的 exec.Command 支持 shell 管道
文件大小:2KB
文件格式:ZIP
更新时间:2021-06-13 01:48:28
Go
去壳管
为了在 go 中运行管道 shell 命令,从单个字符串(在空白处拆分),
s, err := pipes.RunString("ps aux | grep usr")
或作为参数数组,
tokens := []string{"ps", "aux", "|", "grep", "usr", "|", "awk", "{print $2}"}
s, err := pipes.RunStrings(tokens...)
或者,去管道:
cmd1 := exec.Command("ps", "aux")
cmd2 := exec.Command("grep", "usr")
cmd3 := exec.Command("awk", "{print $2}")
cmds := []*exec.Cmd{cmd1, cmd2, cmd3}
pipes.AssemblePipes(cm
【文件预览】:
go-shell-pipes-master
----exec.go(2KB)
----exec_test.go(1KB)
----README.md(582B)