`find`的古怪行为 [英] An odd behavior of `find`

查看:205
本文介绍了`find`的古怪行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的获取/ EVS / ,没有子文件夹中,我有这应该列出中的所有文件的命令取。/ EVS / * EV 不包含文本'错误

Under my fetch/evs/, there is no sub-folder, I have a command which is supposed to list all the files of fetch/evs/*.ev which don't contain text ' Error:

find . -ipath '*/fetch/evs/*.ev' | xargs grep -L -e "' Error" > try0.txt

此命令将返回692文件。奇怪的是,它忽略了符合条件的文件的一部分,例如,如果我做的:

This command returns 692 files. What is odd is that it ignores a part of files which satisfy the criteria, for instance if I do:

find . -ipath '*/fetch/evs/grades*.ev' | xargs grep -L -e "' Error" > try1.txt

这个命令在所有返回72文件,这是不是在 try0.txt

This command returns 72 files which are not in try0.txt at all.

我真的不明白这...谁能帮助?

I really cannot understand this... Could anyone help?

EDIT1:我才意识到,我省略了非常重要的信息,实际上是一个消息在命令后提出: xargs的:无与伦比的单引号;默认情况下,除非你使用-0选项报价是特别的xargs的。此命令会停止在其名称中包含 文件经历。为了解决这个问题,我想:

I just realize that I omitted a very important information, actually a message is raised after the command: xargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 option. And the command does stop going through at a file whose name contains '. To correct this, I tried:

find . -ipath '*/fetch/evs/*.ev' | xargs -0 grep -L -e "' Error" > try3.txt

返回 xargs的:参数线太长 0文件

我也试过:

find . -ipath '*/fetch/evs/*.ev' -print0 | xargs -0 grep -L -e "' Error" > try4.txt

这不会停止在所有....

which does not stop at all....

没有人有任何想法?

推荐答案

您不会碰上的xargs code> -exec

说:

find . -ipath '*/fetch/evs/*.ev' -exec sh -c "grep -L -e \"' Error\" {}" \;

使用 SH 需要在的grep 模式单引号的照顾。

Using sh takes care of the single quote in the grep pattern.

编辑:没有 SH

find . -ipath '*/fetch/evs/*.ev' -exec grep -L -e "' Error" {} \;

这篇关于`find`的古怪行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆