```脚本名:find_file.py
import os
import sys
def findfile(start, name):
for relpath, dirs, files in os.walk(start):
if name in files:
full_path = os.path.join(start, relpath, name)
print(os.path.normpath(os.path.abspath(full_path)))
if __name__ == '__main__':
findfile(sys.argv[1], sys.argv[2])
```
``` 示例:
执行:
python find_file.py '/sbin/aio/box_dashboard/' 'models.py'
结果:
/sbin/aio/box_dashboard/apiv1/models.py
/sbin/aio/box_dashboard/report_system/models.py
/sbin/aio/box_dashboard/web_guard/models.py
/sbin/aio/box_dashboard/web_guard/sitespider/sitespider/models.py
/sbin/aio/box_dashboard/xdashboard/models.py
```