$ dpkg -l | grep -E '^.. +a.*'
Why is that so?
First grep -E
allows to use a regexp
and here the portion between the single quotes is one way to express your wish in a regexp.
^
- do the following at the beginning of each line.
..
- "skip" the first two characters (match anything)
+
- require one space, allow any more of spaces skip them.
a
- the a requirement
.*
- allow zero or more of any other characters.
... and all this due to how the output of dpkg -l looks; the first ten lines are:
$ dpkg -l | head -n 10
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-=============================================-========================================-============-================================================================================
ii accountsservice 23.13.9-2ubuntu6 amd64 query and manipulate user account information
ii acl 2.3.2-1build1 amd64 access control list - utilities
ii adduser 3.137ubuntu1 all add and remove users and groups
ii adwaita-icon-theme 46.0-1 all default icon theme of GNOME
ii alsa-base 1.0.25+dfsg-0ubuntu7 all ALSA driver configuration files
More on regex'es: https://www.rexegg.com/regex-quickstart.php