【问题标题】:redirecting console output to a file in unix将控制台输出重定向到Unix中的文件
【发布时间】:2014-01-09 06:12:13
【问题描述】:

我一直在尝试使用 find 命令在我的 ftp 服务器中搜索文件

find ./* -iname "MyLog.log"

我得到了非常大量的输出。我正在尝试使用以下命令将此输出重定向到文件中。

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

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

我仍然可以在控制台中看到输出,但在文件中看不到。

当我们在 unix 中使用 find 命令时,谁能帮我将输出重定向到文件。

【问题讨论】:

    标签: linux unix redirect console output


    【解决方案1】:

    可能大量的输出是“权限被拒绝”类型的消息。通过附加 2>&1 将错误重定向到日志文件。

    2是stderr的流号(错误信息),1代表stdout流(标准的非错误输出流)。

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

    【讨论】:

      猜你喜欢
      • 2023-03-19
      • 1970-01-01
      • 2021-10-21
      • 2013-12-07
      • 1970-01-01
      • 2013-11-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多