Putting the last two answers together more concisely…
redirect_stdout(devnull) do ... end
EDIT: Should have tested it, it does not work . This does:
redirect_stdout(open(tempname(), "w")) do; println(1) end
although it’s clearly suboptimal. I’d love to get an answer to this question…