I tried to print all the files' name of a directory:
import os
dir = '/etc'
def fr(dir):
filelist = os.listdir(dir)
for i in filelist:
fullfile = os.path.join(dir, i)
if not os.path.isdir(fullfile):
print(fullfile)
else:
fr(fullfile)
fr(dir)
But the result is like bellow:
.....
/etc/man.conf
/etc/manpaths
/etc/master.passwd
/etc/master.passwd~orig
/etc/my.cnf
/etc/my.cnf.bak
/etc/nanorc
/etc/networks
/etc/networks~orig
/etc/newsyslog.conf
/etc/nfs.conf
/etc/nfs.conf~orig
/etc/notify.conf
.....
You know, under the /etc/ssh/
, there are many files, but it did not print, only print the first level files. the second level files and more deep files did not print.
Someone can help me to print all the files name?