I'm currently implementing a docker automation to check whether the number of files in the host mount is equal to docker container mount.
The thing I need to implements
cd <source\location\host>
ls | wc -l
I'm not getting proper value but when I converted the same into python using below code. Geting some other value which does not match with ls | wc -l
files = folders = 0
t = Timer(self._seconds, self._stop_loop)
t.start()
for _, dirnames, filenames in os.walk(path):
if self._loop_stop:
break
# ^ this idiom means "we won't be using this value"
files += len(filenames)
folders += len(dirnames)
t.cancel()
return folders + files
Can anyone help me to identify if this is right approach. If there is an alternative way then kindly share with me.
Thanks in advance.