Find all lines in the file /var/log/messages that do not start with '#' or are empty, sort them, count the number of occurrences of each line, and sort the output by the number of occurrences in descending order.
egrep -v '^#|^$' /var/log/messages | sort | uniq -c | sort -nr