-1

似乎这应该有效,我发现的所有其他示例似乎都表明它会但它不会。

这是一个简短的小脚本,用于查找大小超过 1gb 的所有 error_log 文件。像这样工作正常,打印到 shell 窗口:

find /home -type f -name error_log -size +1048576k

但是当我用这个尝试时:

find /home -type f -name error_log -size +1048576k > output.txt

...我什么也得不到。

当然,我已经测试了这个搜索小得多的文件,服务器上应该有很多文件,如下所示:

find /home -type f -name error_log -size +50k > output.txt

... 依然没有。

也试过:

find /home -type f -name error_log -size +50k >> output.txt

find /home -type f -name error_log -size +50k -print > output.txt

..等等,但没有运气。

更新:

我一直在尝试几乎所有方法来让它发挥作用。我最近的尝试,这让我得到了很多,也就是说,写到了 shell 窗口:

查找 /home -type f -size +100k -name error_log -exec ls -lh {} \; | awk '{ 打印 }'

然而,这让我只有一个空白的 .txt 文件:

查找 /home -type f -size +100k -name error_log -exec ls -lh {} \; | awk'{打印>“zzzoutput.txt”}'

以上应该可行,对吧?

4

1 回答 1

1

-name error_log 表示准确查找所有名称为 error_log 的文件。但是,我猜您的日志文件可能有 error_log.1 error_log.2 等模式,无法通过 -name error_log 匹配。

于 2013-08-11T13:47:07.643 回答