Search code examples
filetreegrepglob

Text specification for a tree of files?


I'm looking for examples of specifying files in a tree structure, for example, for specifying the set of files to search in a grep tool. I'd like to be able to include and exclude files and directories by name matches. I'm sure there are examples out there, but I'm having a hard time finding them.

Here's an example of a possible syntax:

*.py *.html
*.txt *.js
-*.pyc
-.svn/
-*combo_*.js

(this would mean include file with extensions .py .html .txt .js, exclude .pyc files, anything under a .svn directory, and any file matching combo_.js)

I know I've seen these sorts of specifications in other tools before. Is this ringing any bells for anyone?


Solution

  • There is no single standard format for this kind of thing, but if you want to copy something that is widely recognized, have a look at the rsync documentation. Look at the chapter on "INCLUDE/EXCLUDE PATTERN RULES."