func ExampleRead() { grep := sh.Cmd("grep") name := "ExampleReadTest" f, cleanup := openTempFile(name, SWCrawl) defer cleanup() fmt.Print(sh.Pipe(sh.Read(f), grep("far"))) // output: // A long time ago, in a galaxy far, far away.... }
func ExampleDump() { grep := sh.Cmd("grep") name := "ExampleDumpTest" defer writeTempFile(name, SWCrawl)() // Equivalent of shell command // $ cat ExampleDumpTest | grep far fmt.Print(sh.Pipe(sh.Dump(name), grep("far"))) // output: // A long time ago, in a galaxy far, far away.... }
func ExamplePipe() { echo := sh.Cmd("echo") // note, you can "bake in" arguments when you create these functions. upper := sh.Cmd("tr", "[:lower:]", "[:upper:]") grep := sh.Cmd("grep") // Equivalent of shell command: // $ echo Hi there! | grep -o Hi | wc -w fmt.Print(sh.Pipe(echo(SWCrawl), grep("far"), upper())) // output: // A LONG TIME AGO, IN A GALAXY FAR, FAR AWAY.... }