Skip to content

Wrapper around os/exec allowing easy piping of commands

License

Notifications You must be signed in to change notification settings

gurupras/go-simpleexec

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-simpleexec

Wrapper around os/exec allowing easy piping of commands

Install

go get -u github.com/gurupras/go-simpleexec

Usage

package main

import (
        "bytes"
        "fmt"
        "strings"

        "github.com/gurupras/simple-exec"
)                                                               

func main() {
        buf := bytes.NewBuffer(nil)                             

        cmd := simpleexec.ParseCmd("man df").Pipe("grep inode").Pipe("wc -l").Pipe(`sed -e 's/2/4/g'`)
        cmd.Stdout = buf                                        

        cmd.Start()                                             
        cmd.Wait()                                              

        fmt.Printf("Found %v lines containing the word inode\n", strings.TrimSpace(buf.String()))
}

Found 4 lines containing the word inode

About

Wrapper around os/exec allowing easy piping of commands

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages