AnyCompiler

Redirection and Heredocs

> redirects a command's standard output to a file instead of the screen (overwriting it), and 2> does the same for standard error specifically — the two are separate streams. Redirecting either one to the special file /dev/null discards it entirely, which is the standard way to silence output you don't care about.

ls /nonexistent-path-xyz 2>/dev/null
echo "done"
Output
done

A heredoc (<<EOF ... EOF) feeds multiple lines of literal text to a command as if they'd been typed at a prompt — useful for inline multi-line text without a separate file.

cat <<EOF
line one
line two
EOF
Output
line one
line two

Next: case statements — pattern-matching against a value with glob-style patterns.

Practice exercise

Using a heredoc with cat, print exactly these two lines: step one, then step two.