0

I'm trying to get the following recipe to work:

recent_py:
    find . -cmin -60 | egrep '*.py$\' 

And am getting the following error when calling it:

> make recent_py
find . -cmin -60 | egrep '*.py'

The error being that the $ is ignored, so the regex used isn't the regex that I intended (so .pyc files are matched for example)

How can I edit the regex so that it works as I would expect it to when called from the terminal?

edit

updating to

recent_py:
    find . -cmin -60 | grep -E '\.py$'

gives error:

> make recent_py
find . -cmin -60 | grep -E '\.py
/bin/sh: 1: Syntax error: Unterminated quoted string
make: *** [Makefile:81: recent_py] Error 2

answer

recent_py:
    find . -cmin -60 | grep -E '\.py$$'
baxx
  • 3,956
  • 6
  • 37
  • 75

1 Answers1

2

Use grep -E instead (as egrep: warning: egrep is obsolescent):

find . -cmin -60 | grep -E '\.py$'

Or via find's param -regex:

find . -cmin -60 -regex '.*\.py'
RomanPerekhrest
  • 88,541
  • 4
  • 65
  • 105