Here is what came up withL

func TestGrep1(t *testing.T) {
cmd := exec.Command("./read.bash")
fmt.Printf("%v\n", cmd)
stdout, err := cmd.StdoutPipe()
if err != nil {
log.Fatal(err)
}
if err := cmd.Start(); err != nil {
log.Fatal(err)
}
fmt.Printf("%v\n", stdout)
find := []byte{'b', 'u', 'f', 'i', 'o'}
grep(find, stdout, os.Stdout)
actual := ""
expected := ""
if actual != expected {
t.Fatalf("Input %s. Expected: %s, actual: %s\n", actual, expected, actual)
}
}

////////////
read.bash
/////////////
#!/usr/bin/env bash
echo cat Grep1.go
cat Grep1.go


On Saturday, May 7, 2022 at 1:46:33 PM UTC-7 Jan Mercl wrote:

> On Sat, May 7, 2022 at 10:24 PM Constantine Vassilev <[email protected]> 
> wrote:
>
> > I need to write a program that reads STDIN and should output every line 
> that contains a search word "test" to STDOUT.
>
> Piping the data through grep(1) would be my first option.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/9d8b8c95-6444-4ed4-a5d3-9ce86d670819n%40googlegroups.com.

Reply via email to