Created
April 20, 2020 16:23
-
-
Save ahmetozer/b4aeeedd2c4a86e4dc56669602cd94be to your computer and use it in GitHub Desktop.
Golang Multiple exec.Command at same time with pipelining
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
// "fmt" | |
"os/exec" | |
"os" | |
) | |
func main() { | |
topCommand := exec.Command("top","-d 0.5", "-b", "-n 5") | |
awkCommand := exec.Command("grep", "bash") | |
awkCommand.Stdin, _ = topCommand.StdoutPipe() | |
awkCommand.Stdout = os.Stdout | |
_ = awkCommand.Start() | |
_ = topCommand.Run() | |
_ = awkCommand.Wait() | |
//fmt.Println(awkCommand) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment