I am trying to display all files which contain a specific word on more then three lines.
i.e. file:
Andrew is so nice,
and Andrew want some ice,
but Andrew doesn't roll the dice.
So this file contains Andrew on more than three lines, so it will be displayed.
I used grep -or '\' but it list all files which contain "word" on at least 1 line.
Try
It works because grep -c prints "file:count" for each file, and
-F:
tells awk that the colon separates fields.The following shell script may be useful:
The script should be run with two arguments:
DIRECTORY
- the directory where you want to search for files which contains a word on more then three linesSTRING
- the word for seeking.Or, in a single command for files from the current directory and the word "Andrew":