[LearnAdmin] Bash script to find average file size in a directory

30 views
Skip to first unread message

Naresh Surampudi

unread,
Dec 5, 2012, 5:25:44 AM12/5/12
to learnadmin+g...@googlegroups.com
If you want output in Kb


 ls -l | awk '{s+=$5} END {print "Average file size: " s/NR/1024 "k"}'
Average file size: 28683.4k

If you want output in MB
ls -l | awk '{s+=$5} END {print "Average file size: " s/NR/1024/1024 "MB"}'
Average file size: 28.0112MB

If you want output in GB

ls -l | awk '{s+=$5} END {print "Average file size: " s/NR/1024/1024/1024 "GB"}'
Average file size: 0.0273546GB





--
Posted By Naresh Surampudi to LearnAdmin at 12/05/2012 03:55:00 PM
Reply all
Reply to author
Forward
0 new messages