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
  • 66,199
  • 35
  • 114
  • 250
Ivan Ivanov
  • 19
  • 1
  • 2

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
  • 234,489
  • 66
  • 447
  • 667
  • @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,866
  • 1
  • 10
  • 21