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