Reply To: How to sort a list of specific installed packages by size?

Forum › Forums › New users › New Users and General Questions › How to sort a list of specific installed packages by size? › Reply To: How to sort a list of specific installed packages by size?

#190874
hughtmccullough
Member

    OK. The search the grep command is doing is too simple. To see what is happening you can look at your size.txt file and examine the entries that don’t appear in the specifics.txt file. For instance in size.txt there are several erroneous entries that start with ‘dinit-service-…’ This happens because the specifics.txt file contains the line ‘dinit’ and every line in the dpkg query that contains ‘dinit’ gets through the filter. To avoid this the search needs to be more specific.

    If you change the search pattern from ‘dinit’ to ‘ dinit$’ then grep will only find lines that have ‘dinit’ if there is a space before it and it occurs at the end of the line. It is fairly easy to achieve this in geany by changing the search and replace of your list of packages to search for spaces, as before, but replace them with ‘$\n ‘ (don’t forget to include the space in that). There is one more thing to do to tidy it up. Add a space at the beginning of the first line and remove the space on the extra line at the bottom.

    You should take the time to learn the tools you are using. grep and other command line tools are very powerful but only if you know what they can do. A good place to start is by typing ‘man grep’ in a terminal and scroll down as you read. It can look a bit intimidating but if you don’t understand something a quick search usually gets you the information you need. There are loads of resources that cover this sort of thing.