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?

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

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

 find ~+ -name '*.h'
  • @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 '17 at 12:04

You need something like this:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.