List and sort out Installed Packages according to time

How to list and sort out Installed Packages according to time in terminal ?
I hav being looking for a tool to sort any output according to time and size … but can’t find any… I sure know there is… but all the help of such topic ultilized $ls command which i don’t want. I want my any listing tool to pipe it to sort out according to time; it can be pacman or any other tools.

pacman -Q | sort ???

Learn to use search engines :wink:

You can’t - at least not via pacman directly.


But in that thread you’ll find a lot of interesting ways to do this with ls or pacman’s log :upside_down_face:

That one is pretty neat:

find /var/lib/pacman/local/ -mindepth 1 -maxdepth 1 -type d -printf "%TY-%Tm-%Td %TH:%TM %P\n" | sort

I did searched many pages of google, found a lot of sorting from $ls listing… which is not what i am looking for.

This one works… but i was trying to look for other way that does not require download of expac

expac --timefmt=%s '%b\t%n' | sort -n

Depends on what you are after and why. For example, do you mean pacman log?

How about these two alternative commands:

  ls -ltr /var/cache/pacman/pkg

  sudo pacman -S pahis --needed ; pahis

Well, search is an art, not very easy one, it matters how you ask a question, for example i’ve used that in duckduckgo:

pacman sort installed packages by date

And that was 1st link.

In general you want to keep as brief and as point as you can when making question for robot :robot:


Are you meaning that All Installed package are 100% listed in /var/cache/pacman/pkg ?
I just tried this command, but it does not sort out my latest installed package neither on top or at bottom.

May i know why install pahis ? Why not expac ?
Well, i tried to install less tools, more tools means more unstable or space used.
But if there is no other endea Os own method, then i will choose external tools.

Have you tried my 1st reply command?
It doesn’t require additional tools

I have located this method:
awk '/%NAME%/{getline;PKG=$1} /%INSTALLDATE%/{getline;IDATE=strftime("%Y-%m-%d %H:%M",$1);print IDATE" "PKG}' /var/lib/pacman/local/*/desc|sort
I think this is an Os Own tools…

Oh ya… I missed out. Was busy reading and searching fr google.
ya… your method works good.
I will use that method than.
However i really wonder how can anybody remember these long winded cmd in head ? How did you remember ?

Save it somewhere in your personal cheat-sheet file or utility bash script even :laughing:
With time you can learn even obscure stuff like find, however memory works in mysterious ways so it’s better to save what you really need.

1 Like

You really can remember by heart ? or you use cheat sheet method. I do use vim to note all these down.

find more or less yes now, coz i use it a lot in my scripts, yet i hated it always because of weird syntax…

Well… I have no idea what you are looking for and why, you weren’t particularly exact in your original question.
For example, I don’t know what you mean by time, is it: when something was installed, or when is the latest install of something, etc.

So I provided one answer that can show you lots of things about your install history.
If you need specific tools, you should specify exactly what you are after, and why. Otherwise helping is quite challenging.

You can do this

grep "\[ALPM\] installed" /var/log/pacman.log

It will list all packages according to their install date (not when they were last updated!). But if you removed some packages, they will still be listed, because they were installed at some point. We can also list all the packages and their removal dates and do some programming to filter the list, but that requires effort :slight_smile:


I have never liked trying to remember such things. On my desktop, I keep a file where i can quickly open it, copy the string or even a good tip to it. I use Kate for that.

1 Like

Btw, i like idea of Deepin terminal (not sure if there are similar ones out there), it has something like shortcuts when you open your list of those and just lmb to execute command…

Cool idea :slight_smile:


This will also list packages which has since been removed - but it does what was requested in the subject of OT.

Yes, like I said in the post. If that is an issue, a simple awk program could be made to check if a package is installed, before listing it.

1 Like

I found this, check it out, give it a try.