redirecting console output to a file in unix

烂漫一生 提交于 2019-12-01 20:26:17

问题


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.


回答1:


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


来源:https://stackoverflow.com/questions/20702652/redirecting-console-output-to-a-file-in-unix

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!