Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 228
Prathap Avatar asked Dec 20 '13 11:12

Prathap


People also ask

How do I redirect a output to a file in Unix?

In Linux, for redirecting output to a file, utilize the ”>” and ”>>” redirection operators or the top command. Redirection allows you to save or redirect the output of a command in another file on your system. You can use it to save the outputs and use them later for different purposes.

How do I redirect console output to a file?

To redirect the output of a command to a file, type the command, specify the > or the >> operator, and then provide the path to a file you want to the output redirected to. For example, the ls command lists the files and folders in the current directory.

How do I redirect all output to a file in Linux?

As redirection is a method of capturing a program output and sending it as an input to another command or file. The I/O streams can be redirected by putting the n> operator in use, where n is the file descriptor number. For redirecting stdout, we use “1>” and for stderr, “2>” is added as an operator.

How do I redirect an output?

Redirecting OutputThe > symbol is used to redirect output by taking the output from the command on the left and passing as input to the file on the right.


1 Answers

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
like image 146
suspectus Avatar answered Oct 01 '22 07:10

suspectus