github twitter linkedin email
Multiple text file size : small intro to find and awk
Apr 20, 2012
One minute read

People are used to just open a file explorer, select multiple files, right click and check size. Unfortunately you can’t do that when you work in a terminal through an ssh connexion. In bash, one can do the following to track the size of all the files harboring a final .txt :

find ./ -name "*.txt" -ls | awk '{total += $7} END {print "Total size: " total/1024/1024 " Mb"}'

There are other commands to get this done, this is one I like because I can easily specify a file pattern that I am looking for.

Back to posts

comments powered by Disqus