Paul - The Programmer

simple & stupid
Possible solution for VNC clipboard doesn't work
Use -prune to skip directory while finding file

use regular expression to find files

paul posted @ Thu, 04 Jun 2009 20:28:23 +0800 in coding life , 1377 readers

Say you want to list all the *.py, *.cc and *.h files.

You may use the command below.

find ./ -name '*.cc' -o -name '*.h' -o -name '*.py'

But there is always a better way! So, give a try to the option -regex.

find . -regex '.*\.\(cc\|h\|py\)'

What's the backslashes in expression used for?  Well, the find command uses emacs regular expression syntax!

Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 Unported License.
  • No match
  • No match

Login *


loading captcha image...
(type the code from the image)
or Ctrl+Enter