echo one >f; cat f echo two >>f; cat f cat &2 2>/dev/null echo err2 >&2 2>/dev/null { echo out; echo err >&2; } 2>&1 | sort { echo out; echo err >&2; } >g 2>&1; cat g exec 3>h; echo via3 >&3; exec 3>&-; cat h exec 4f b c; cat f >empty; test -f empty && test ! -s empty && echo empty-ok echo clob >f; set -C; (echo no >f) 2>/dev/null; echo "noclobber $?"; echo yes >|f; cat f; set +C (cat /dev/null; echo "missing $?" (echo x >/nonexistent/dir/file) 2>/dev/null; echo "baddir $?" : >f; echo rw 1<>f; cat f while read a; do echo "got $a"; done f; cat f if true; then echo cond; fi >f; cat f f() { echo infunc; }; f >f; cat f (echo sub; echo sub2 >&2) >f 2>&1; cat f echo keep; echo gone >/dev/null; echo kept echo 3 >f 2>&1; cat f exec 5>&1; echo to5 >&5; exec 5>&- (echo bad >&7) 2>/dev/null; echo "badfd $?" cat <f heredoc to file E cat f 2>/dev/null >&2 echo hidden; echo shown n=3; echo dyn >&$((n-2)) true >f; echo "status $?"