I am trying to find files containing a specific word using grep
. There are many files in the directory (> 500)
Command I run
$ grep 'delete' *
Output
validate_data_stage1:0
validate_data_stage2:0
validate_data_stage3:0
validate_data_stage4:0
validate_data_stage5:0
validate_input_stage1:0
validate_input_stage2:0
validate_input_stage3:0
validate_input_stage4:0
.... and hundred of such lines
These are the files that don't contain the given match. I want to suppress those lines from displaying to stdout. I know of -q
switch, but that would suppress the complete output, which I don't want.
How do I do that?
grep
should not print out file names of non-matching files. Actually, it looks likegrep
considers a line with the content0
to be matching. Can you post the exact search pattern you are using?grep 'delete' * -R
, but I don't think-R
is causing any issue. And yes, it normally doesn't print the non-matching ones, but not sure what's the case here...grep -- 'delete' *
(added--
) and it worked as expected. Removing the--
is leading to the above display.-ci
. Thanks for resolving the issue. You can post this scenario as an answer.