Balualways
Balualways

Reputation: 4510

Redirect standard output to a log and standard error to an error log

I have a command, say find . -size +10

I need to redirect the error like "permission denied" to errorlog.txt

find . -size +10 2>errorlog.txt 

And to redirect the normal output to standard log file report.txt

find . -size +10 >report.txt

How to combine these two?

Upvotes: 2

Views: 294

Answers (2)

Lesmana
Lesmana

Reputation: 27053

Like this:

command > stdout.log 2> stderr.log

or, to also see the output on screen:

(command | tee stdout.log) 3>&1 1>&2 2>&3 | tee stderr.log

Upvotes: 2

SiegeX
SiegeX

Reputation: 140367

some_command > report.txt 2> errorlog.txt

Upvotes: 2

Related Questions