To calculate the average file size within a directory on a Linux system, following command can be used:
ls -l | gawk '{sum += $5; n++;} END {print sum/n;}'
If you'd like to know the average size of some particular kind of files (like jpg files) then use the following:
ls -l *.jpg | gawk '{sum += $5; n++;} END {print sum/n;}'