This may be a duplicate as I believe I already saw something like that but can't find it anymore so I'm asking :
这可能是重复的,因为我相信我已经看到了类似的东西但是找不到它所以我问:
I have a lots of files with multiple lines, and in most case, one of the line contain a certain patern. I would like to have every file that do not have a line with this patern.
我有很多具有多行的文件,在大多数情况下,其中一行包含某个patern。我想让每个文件都没有这个patern的行。
EDIT : Just need to use the "-L" grep option. This is a duplicate, I'm sure but don't find the original back ...
编辑:只需要使用“-L”grep选项。这是重复的,我敢肯定,但没有找到原来的背...
3 个解决方案
#1
25
The answer was just to get the "-L" option in order to have file WITHOUT the pattern ... Should have read the man more carefully!
答案只是为了获得“-L”选项以使文件没有模式......应该更仔细地阅读这个人!
#2
6
Grep returns 0/1 to indicate if there was a match, so you can do something like this:
Grep返回0/1表示是否匹配,所以你可以这样做:
for f in *.txt; do
if ! grep -q "some expression" $f; then
echo $f
fi
done
EDIT: You can also use the -L option:
编辑:您还可以使用-L选项:
grep -L "some expression" *
grep -L“some expression”*
#3
0
try "count" and filter where equals ":0":
尝试“计数”并过滤等于“:0”:
grep -c [pattern] * | grep ":0"
(if you use TurboGREP cough, you won't have a -L switch ;))
(如果你使用TurboGREP咳嗽,你就不会有-L开关;))
#1
25
The answer was just to get the "-L" option in order to have file WITHOUT the pattern ... Should have read the man more carefully!
答案只是为了获得“-L”选项以使文件没有模式......应该更仔细地阅读这个人!
#2
6
Grep returns 0/1 to indicate if there was a match, so you can do something like this:
Grep返回0/1表示是否匹配,所以你可以这样做:
for f in *.txt; do
if ! grep -q "some expression" $f; then
echo $f
fi
done
EDIT: You can also use the -L option:
编辑:您还可以使用-L选项:
grep -L "some expression" *
grep -L“some expression”*
#3
0
try "count" and filter where equals ":0":
尝试“计数”并过滤等于“:0”:
grep -c [pattern] * | grep ":0"
(if you use TurboGREP cough, you won't have a -L switch ;))
(如果你使用TurboGREP咳嗽,你就不会有-L开关;))