Saxtheowl
Saxtheowl

Reputation: 4658

What does this symbol mean in my Unix command?

I'm doing some tutorial and I see this shell command:

find / -name foo 2>/dev/null

What does the last token do? Specifically, the 2? I get that the > redirection will send the shell output to a file, but how does find get only the error message ?

Upvotes: 0

Views: 86

Answers (1)

user3553031
user3553031

Reputation: 6214

2>/dev/null means to redirect stderr to /dev/null. The 2 comes from the file descriptor for stderr; stdin is always 0, stdout is always 1, and stderr is always 2. The default source for output redirection is stdout, so >/dev/null has the same meaning as 1>/dev/null.

By the way, that's a shell feature; it's not specific to find.

Upvotes: 5

Related Questions