# Removing pkgs installed in the last day



## balanga (Apr 1, 2021)

Does `pkg install` record when a pkg was installed? If so, then maybe I could work out how to remove pkgs installed in the last day... Sometimes when trying to get something to work you install all sorts of pkgs until a program works, but you don't really know how many of those pkgs you installed were actually necessary...


----------



## zirias@ (Apr 1, 2021)

`pkg query -a '%t %n' | sort`


----------



## SirDice (Apr 1, 2021)

You can also check /var/log/messages, packages being installed, deleted or upgraded is recorded there too.


----------



## zirias@ (Apr 1, 2021)

You can combine that to do what you want in a oneliner:

```
pkg query -e "%t >= $(($(date +%s) - 86400))" %n | xargs pkg remove
```
(not sure whether this works in a C shell…)


----------

