I would like to count how much space taking Qt4 libraries for the MacOSX universal build of one from our application. So I used following command:
du -m * | sort -nr | grep Qt | awk '{sum+=$1} END {print sum}'
- du -m - print used size in megabytes (for directory do not forgot about -s option);
- sort -nr - sort in reverse, numerical order;
- grep Qt - left only lines with Qt (you can also first grep and next sort lines);
- {sum+=$1} - adding a value from first column of each line to variable sum;
- END {print sum} - printing variable sum on after going through all of lines.
2 comments:
Sorting is needless. It was me, optimization freak. ;)
You are 100% right.
Sorting was needed for checking which libraries are the biggest. That time I didn't used awk part of the command.
Post a Comment