설치된 패키지가 있는 경우 정확한 이름으로 어떻게 찾나요?

설치된 패키지가 있는 경우 정확한 이름으로 어떻게 찾나요?

특정 패키지가 설치되어 있는지 확인하고 싶습니다. 정확히 일치하는 항목이 필요합니다.

nginx로 시작하는 패키지를 찾을 수 있습니다.

$ dpkg -l | grep -w 'nginx'
ii  nginx                                1.18.0-0ubuntu1                   all          small, powerful, scalable web/proxy server
ii  nginx-common                         1.18.0-0ubuntu1                   all          small, powerful, scalable web/proxy server - common files
ii  nginx-core                           1.18.0-0ubuntu1                   amd64        nginx web/proxy server (standard version)

$ dpkg -l | grep -w 'nginx$'

$ dpkg -l | grep -w "nginx"
ii  nginx                                1.18.0-0ubuntu1                   all          small, powerful, scalable web/proxy server
ii  nginx-common                         1.18.0-0ubuntu1                   all          small, powerful, scalable web/proxy server - common files
ii  nginx-core                           1.18.0-0ubuntu1                   amd64        nginx web/proxy server (standard version)

$ dpkg -l | grep -w "\<nginx\>"
ii  nginx                                1.18.0-0ubuntu1                   all          small, powerful, scalable web/proxy server
ii  nginx-common                         1.18.0-0ubuntu1                   all          small, powerful, scalable web/proxy server - common files
ii  nginx-core                           1.18.0-0ubuntu1                   amd64        nginx web/proxy server (standard version)

$ dpkg -l | grep  "\<nginx\>"
ii  nginx                                1.18.0-0ubuntu1                   all          small, powerful, scalable web/proxy server
ii  nginx-common                         1.18.0-0ubuntu1                   all          small, powerful, scalable web/proxy server - common files
ii  nginx-core                           1.18.0-0ubuntu1                   amd64        nginx web/proxy server (standard version)

그리고 나는 단지 nginx를 원합니다. 어떻게 고치나요?

답변1

설명된 대로패키지가 dpkg에 있지만 apt를 통해 설치할 수 없습니다., 사용 dpkg-query:

dpkg-query -W -f '${db:Status-Status}' nginx

nginx"설치됨"은 해당 패키지가 완전히 설치된 경우에만 나타납니다.

그래도 문제가 해결되지 않으면 dpkg-query패키지를 매개변수로 지정하세요 dpkg -l.

dpkg -l nginx

답변2

필터링된 출력 dpkg -l:

dpkg -l | awk /^ii/'{print $2}' | grep -w nginx$

( )와 같은 결과 sudo apt install dctrl-tools:

grep-status -FStatus -sPackage -n  "install ok installed" |grep -w  nginx$

관련 정보