#!/usr/bin/python
# -*- coding:utf8 -*-
import os
sub_str = "interface TenGigabitEthernet"
#def get_file_content(file):
#filecon = open()
def get_dir(path):
files = os.listdir(path)
for file in files:
if file[0] == '.':
pass
if os.path.isdir(file):
get_dir(path+'/'+file)
else:
file_name = path + '/' + file
with open(file_name) as file_obj:
for content in file_obj:
if content.find(sub_str) != -1:
print(file_name)
if __name__ == '__main__':
# file_content = open("file_content.txt", "wb")
path = "/root/v2.75"
get_dir(path)
05-30
4万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
10-01
1万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)