""import ossysfind heregets tools find count for filename in find find('pyc'sys argv[ ])count + print(filenameos remove(filenameprint('removed % pyc filescountwhen runall bytecode files in the tree rooted at the passed-in directory name are removed as beforethis timethoughour script works just about everywhere python doesc:\pp \toolscleanpyc-find-py py \find pyc \visitor pyc \__init__ pyc removed pyc files this works portablyand it avoids external program startup costs but find is really just half the story--it collects files matching name pattern but doesn' search their content although extra code can add such searching to find' resulta more manual approach can allow us to tap into the search process more directly the next section shows how python tree searcher after experimenting with greps and globs and findsin the endto help ease the task of performing global searches on all platforms might ever usei wound up coding task-specific python script to do most of the work for me example - employs the following standard python tools that we met in the preceding os walk to visit files in directoryos path splitext to skip over files with binary-type extensionsand os path join to portably combine directory path and filename because it' pure python codeit can be run the same way on both linux and windows in factit should work on any computer where python has been installed moreoverbecause it uses direct system callsit will likely be faster than approaches that rely on underlying shell commands example - pp \tools\search_all py ""###############################################################################use"python \tools\search_all py dir stringsearch all files at and below named directory for stringuses the os walk interfacerather than doing find find to collect names firstsimilar to calling visitfile for each find find result for "*patternsearching directory trees