Found this while surfing:
Taken from: http://tutorials.papamike.ca/pub/fbsd-ports2.html
Code:
#!/bin/sh
# top30ports.sh
# it shows a listing of the 30 largest ports
top=30
newline='\
'
echo "The largest $top packages on your system"
echo "--------------------------------------"
echo "Size (kB) Package"
echo "--------------------------------------"
pkg_info -as | \
tr '\n' ' ' | \
sed -e 's/Package Size://g' \
-e "s/(1K-blocks)/$newline/g" | \
tr ':' ' ' | \
awk '{print$4," ",$3}' | \
sort -gr | \
head -"$top"
Taken from: http://tutorials.papamike.ca/pub/fbsd-ports2.html