blob: d784dc26b3a59a307cbc96b1b72035e3f3875dc8 [file] [log] [blame]
mtkleinb91f7562015-05-16 15:47:10 -07001# Copyright 2015 Google Inc.
2#
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6'''
mtkleinada5a442016-08-02 14:28:26 -07007find.py is a poor-man's emulation of `find -name=$1 $2` on Unix.
mtkleinb91f7562015-05-16 15:47:10 -07008
mtkleinada5a442016-08-02 14:28:26 -07009Call python find.py <glob> <directory>... to list all files matching glob under
mtkleinb91f7562015-05-16 15:47:10 -070010directory (recursively). E.g.
mtkleinada5a442016-08-02 14:28:26 -070011 $ python find.py '*.cpp' ../tests/ ../bench/
12will print all .cpp files under ../tests/ and ../bench/.
mtkleinb91f7562015-05-16 15:47:10 -070013'''
14
15import fnmatch
16import os
17import sys
18
mtkleinada5a442016-08-02 14:28:26 -070019for directory in sys.argv[2:]:
20 for d, kids, files in os.walk(directory):
21 files.sort()
22 for f in files:
23 if fnmatch.fnmatch(f, sys.argv[1]):
24 print os.path.join(d, f).replace('\\', '/') # Gyp wants Unix paths.