Esempio n. 1
0
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....
}
Esempio n. 2
0
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....
}
Esempio n. 3
0
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....
}