0

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?

Benjamin W.
  • 46,058
  • 19
  • 106
  • 116
  • see also [Find text within a given directory, recursively](https://stackoverflow.com/documentation/grep/2198/getting-started-with-grep/10692/find-text-within-a-given-directory-recursively#t=201611080646111179158) – Sundeep Nov 08 '16 at 06:46

1 Answers1

1
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.

Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360
  • `^.*` and `.*` are not needed... need to use `-E` option or `\{3\}`.. also, better to use single quotes instead of double if substitution is not needed... see [How do I grep recursively?](https://stackoverflow.com/questions/1987926/how-do-i-grep-recursively) for grep versions without `-r` option... – Sundeep Nov 08 '16 at 06:45
  • @Sundeep I updated my answer, thanks for the feedback. – Tim Biegeleisen Nov 08 '16 at 07:24