Turns out that there is a function *readandwrite() <http://docs.julialang.org/en/release-0.4/stdlib/base/#Base.readandwrite>* which does exactly what we need:
function main()
letters = ["v", "w", "x", "y", "z"]
str = join(["$a$b\n" for a in letters, b in letters])
print("\nBefore grep:\n", str)
(grepout, grepin, grep) = readandwrite(`grep y`)
print(grepin, str)
close(grepin)
filtered_str = readall(grepout)
print("\nAfter grep:\n", filtered_str)
end
main()
