Stephanie Laski
Stephanie Laski

Reputation: 11

Extract occurrences of pattern from multiple files

I am trying to find all occurrences of three characters between a pair of spaces in all files in my current directory.

So far I have

sed 's/.../(&)/g'

I know it's not right; I think I'm stuck on something. How can I do that?

Upvotes: 0

Views: 172

Answers (1)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 521339

grep -r -l ' [a-zA-Z]{3} ' .

Explanation:

-r grep recursively from the current folder (.)
-l only display file names, rather than all matching lines

The regex I used is [a-zA-Z]{3}, which matches three characters in between a pair of spaces, anywhere within a given file.

Upvotes: 1

Related Questions