-1

Suppose I have set of files

fSet: f1, f2, f3, f4, f5, ........... f100

and I set have words

wSet: w1, w2, w3, w4, w5, ...........w100

How I may list files which has one or more word from wSet?

and further

how may I may make a report which not only list files but mentions respective containing words?

and further

how I may handle if word may have special symbol like ip address?

2

Try:

egrep 'w1|w2|...|w100' f1 f2 ... f100

Or better, put your words into a file and do

grep -f filewithwords f1 f2 ... f100
  • in case all files are in same directory I can even use egrep 'w1|w2|...|w100' /path/to/dir/*. thanks – old-monk Jan 18 '18 at 0:31
2
grep --files-with-matches -e w1 -e w2 -e w3 -e w4 -e w5 f1 f2 f3

put the words in a file:

:> cat input
w1
w2
w3
w4
w5

:> grep --files-with-matches --file=input f1 f2 f3
f1
f3

:> grep -o --file=input f1 f2 f3
f1:w2
f3:w4
f3:w5

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.