Skip to content

How to check if a list of apt packages are already installed? #35

Answered by felipecrs
felipecrs asked this question in Q&A
Discussion options

You must be logged in to vote
function is_apt_package_installed() {
  local package="$1"

  apt list --quiet --quiet --installed "${package}" 2>/dev/null | grep --quiet .
}

if is_apt_package_installed curl; then
  echo "curl is installed"
else
  echo "curl is not installed"
fi

Replies: 1 comment

Comment options

felipecrs
Jun 21, 2022
Maintainer Author

You must be logged in to vote
0 replies
Answer selected by felipecrs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant