Skip to content
Justice Tech School

Redirection

> writes, >> appends, < reads, 2> redirects errors and &> redirects both.

Example
f=$(mktemp)
echo one > "$f"
echo two >> "$f"
cat "$f"
ls /nonexistent 2> /dev/null || echo "error hidden"
rm "$f"

Result

one
two
error hidden

Exercise

Append.

echo x  file

Quiz Test

What does 2> do?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.