apt를 사용하여 설치된 패키지 만 검색 aptitude다음과 같이 검색 할

를 사용하면 aptitude다음과 같이 검색 할 수 있습니다.

aptitude search '~i bash'

이것은 적성 특정 정규 표현식 인 것 같습니다. 추가 명령을 사용 apt하거나 사용 apt-cache하지 않고 동일한 작업을 수행 할 수 있습니까?

apt search '~i bash'

작동하지 않는다.



답변

당신은 시도 할 수 있습니다:

apt list --installed bash

설치된 package이름을 이름 으로 나열하려고 시도합니다.bash

그러나 특정 파일을 검색하려면 apt-file

다음 명령은 bash이름 내에 문자열이있는 모든 패키지를 나열합니다 .

apt list -a --installed bash

@Exostor apt list -a --installed bash가 제안한 것처럼 항상 특정 문자열로 시작하는 패키지를 나열하는 것은 아니며 대신 다음을 사용하십시오.

apt list -a --installed bash*

검색하는 것이 globbing 인 경우 아래 @Exostor 의견을 올리십시오.


답변

dpkg-query --list | grep '^.i\s*PKG'

또는:

dpkg-query --list PKG\* | grep '^.i'

여기서 PKG원하는 패키지 이름 / A REG-예이다.


답변

다른 사람 이이 작업을 수행하는 방법을 궁금해하는 경우 다음 방법을 사용합니다.

apt list --installed | grep [XYZ]

이 방법은 또한 검색 한 문자열을 포함하여 설치된 다른 패키지를 보여줍니다. 예를 들어, vlc를 검색하는 경우 이름에 ‘vlc’가있는 다른 많은 패키지가 표시됩니다. 입력 및 출력은 다음과 같습니다.

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]

패키지가 설치되어 있지 않으면 명령이 종료됩니다.