-1

I have this files: a.h, b.h, count.sh. And I use this operation

find . | grep ".h$"

And as result I have all 3 files but want only a.h, b.h? Where is my error?

Cyrus
  • 69,405
  • 13
  • 65
  • 117
dasfex
  • 828
  • 1
  • 4
  • 18
  • This might help: [The Stack Overflow Regular Expressions FAQ](http://stackoverflow.com/a/22944075/3776858) – Cyrus Mar 01 '20 at 16:21
  • the `.` refers to "any single char". to make ita literal `.`, you need to escape it, ie `grep '\.h$' files`. This is a duplicate Q, would you mind just deleting it? Thanks and good luck. – shellter Mar 01 '20 at 16:28
  • Use `find . -name '*.h'` – Cyrus Mar 01 '20 at 16:35

1 Answers1

1

You have to escape the . since this way it match anything since that is its meaning in regex. So try "\.h$".

Eraklon
  • 4,043
  • 2
  • 10
  • 27