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.
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.
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With