search for only installed packages using apt
You can try:
apt list --installed bash
This will try to list the installed package
s with the name bash
However, if you wanted to search for a particular file, use apt-file
The following command will list all the packages that have string bash
within their name:
apt list -a --installed bash
As suggested by @Exostor apt list -a --installed bash
is not always the case to list those packages that start with a particular string, instead use:
apt list -a --installed bash*
If globbing is what you're searching for, please upvote @Exostor comment below.
dpkg-query --list | grep '^.i\s*PKG'
or:
dpkg-query --list PKG\* | grep '^.i'
where PKG
is the desired package name / a reg-ex.
If anybody else is wondering how to go about doing this, I use the following method.
apt list --installed | grep [XYZ]
This method also shows different packages that are installed containing the string you were searching for. For example, if I'm searching for vlc, I'm shown many other packages which also have 'vlc' in their name. Here's input and output:
apt list --installed | grep vlc
WARNING: apt.divert does not have a stable CLI interface. Use with caution in scripts.
browser-plugin-vlc/stable,now 2.0.6-4 amd64 [installed]
libvlc-bin/stable,stable,now 2.2.7-1~deb9u1 amd64 [installed]
libvlc5/stable,stable,now 2.2.7-1~deb9u1 amd64 [installed]
libvlccore8/stable,stable,now 2.2.7-1~deb9u1 amd64 [installed]
phonon4qt5-backend-vlc/stable,now 0.9.0-2 amd64 [installed,automatic]
vlc/stable,stable,now 2.2.7-1~deb9u1 amd64 [installed]
vlc-bin/stable,stable,now 2.2.7-1~deb9u1 amd64 [installed]
vlc-data/stable,stable,stable,stable,now 2.2.7-1~deb9u1 all [installed]
vlc-l10n/stable,stable,stable,stable,now 2.2.7-1~deb9u1 all [installed]
vlc-plugin-base/stable,stable,now 2.2.7-1~deb9u1 amd64 [installed]
vlc-plugin-notify/stable,stable,now 2.2.7-1~deb9u1 amd64 [installed]
vlc-plugin-qt/stable,stable,now 2.2.7-1~deb9u1 amd64 [installed]
vlc-plugin-samba/stable,stable,now 2.2.7-1~deb9u1 amd64 [installed]
vlc-plugin-skins2/stable,stable,now 2.2.7-1~deb9u1 amd64 [installed]
vlc-plugin-video-output/stable,stable,now 2.2.7-1~deb9u1 amd64 [installed]
vlc-plugin-video-splitter/stable,stable,now 2.2.7-1~deb9u1 amd64 [installed]
vlc-plugin-visualization/stable,stable,now 2.2.7-1~deb9u1 amd64 [installed]
If it turns out you don't have the package installed, the command will simply exit.