You can use dpkg-query without grep quite efficiently:
Code:
$ time dpkg-query -Wf '${db:Status-Status}' aptinstalledreal0m0.030suser0m0.023ssys0m0.007s
Statistics: Posted by lindi — 2024-05-31 22:37 — Replies 10 — Views 299