Skip to content

Instantly share code, notes, and snippets.

@trafficinc
Last active July 13, 2018 19:20
Show Gist options
  • Save trafficinc/2a143d2d9f6055207d2b16a17e3ea25a to your computer and use it in GitHub Desktop.
Save trafficinc/2a143d2d9f6055207d2b16a17e3ea25a to your computer and use it in GitHub Desktop.
Python script that will find a file in directories below parent Dir recursively
#!/usr/bin/python3
# use: $ python findFile.py "view.html"
import os,sys
fileLook = sys.argv[1];
rootdir=('/var/www/mysite/public')
for root, directories, filenames in os.walk(rootdir):
try:
for filename in filenames:
if filename == fileLook :
print os.path.join(root,filename)
except IOError:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment