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?

1
  • I you wanto to use a regex with GNU find: find ~+ -regex ".*\.h"
    – Cyrus
    Jun 4, 2017 at 12:36

2 Answers 2

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'
1
  • @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 4, 2017 at 12:04
0

You need something like this:

 find /path/to/directory -name '*.h'
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .