perl -le 'warn "stdout is NOT being redirected/piped" if(-t STDOUT); print "foo"' #### perl ... | grep o #### perl ... > foo.txt