If you only have directories and not files in directory1
, then the following two "commands" should give you the size (in bytes) and name of the largest directory and the average of their sizes (in bytes), respectively.
$ du -sb directory1/* | sort -n | tail -n 1
$ du -sb directory1/* | awk ' { sum+=$1; ++n } END { print sum/n } '
If there is also ordinary files within directory1
, these will be counted as well with the examples above. If ordinary files should not be counted, the following might be more appropriate.
$ find directory1/ -mindepth 1 -maxdepth 1 -type d -exec du -sb {} \; | sort -n | tail -n 1
$ find directory1/ -mindepth 1 -maxdepth 1 -type d -exec du -sb {} \; | awk ' { sum+=$1; ++n } END { print sum/n } '