Prathap
Prathap

Reputation: 85

redirecting console output to a file in unix

I have been trying to search for a file in my ftp server using find command

find ./* -iname "MyLog.log"

I am getting very large amount of output. I am trying to redirect this output into a file using the below commands.

find ./* -iname "MyLog.log"  > ./myfile/storeLog.log

and

find ./* -iname "MyLog.log"  tee ./myfile/storeLog.log

Still I am able to see the output in console but not in file.

Can anyone help me on how can i redirect the output to a file when we use find command in unix.

Upvotes: 5

Views: 17632

Answers (1)

suspectus
suspectus

Reputation: 17258

Possibly the large amount of output is "permission denied" type messages. Redirect errors to the log file by appending 2>&1.

2 is the stream number for stderr (error messages), 1 is represents the stdout stream (the standard non-error output stream).

find . -iname "MyLog.log" > ./myfile/storeLog.log 2>&1

Upvotes: 8

Related Questions