2

Hello I want to find all files in a directory ending with .h and I must use find command,I tried like this :

  find ~+ -name '\.h$'

strangely i have .h files but the command when executed doesn't produce output,so probably there is something wrong with the regex?

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255

2 Answers2

1

The -name takes a shell glob, not a regex. You don't need to and shouldn't escape the .. Just use:

 find ~+ -name '*.h'
terdon
  • 242,166
  • @IvanIvanov you're welcome. If one of these answers solved your problem, please accept it so the question can be marked as answered. – terdon Jun 04 '17 at 12:04
0

You need something like this:

 find /path/to/directory -name '*.h'
NickD
  • 2,926