print file size linux code example
Example 1: list file size as mb
ls -l --block-size=M
Example 2: linux file size
cd dir ; du -hsx * | sort -rh | head -20
Example 3: how to get size of folder python
import os
def get_size(start_path = '.'):
total_size = 0
for dirpath, dirnames, filenames in os.walk(start_path):
for f in filenames:
fp = os.path.join(dirpath, f)
if not os.path.islink(fp):
total_size += os.path.getsize(fp)
return total_size
print(get_size(), 'bytes')
Example 4: linux command for file size
du -bsh *