Skip to content

Instantly share code, notes, and snippets.

@tuananh
Last active November 1, 2023 03:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuananh/1e8e0f921410a830a7cd1161ff8bb189 to your computer and use it in GitHub Desktop.
Save tuananh/1e8e0f921410a830a7cd1161ff8bb189 to your computer and use it in GitHub Desktop.
apt find recursive dependencies of packages
#!/bin/bash
set -eu
declare -a all_deps=( )
for pkg_name in "$@"
do
declare -a deps=$(apt-cache depends -i --recurse $pkg_name | awk -F 'Depends: ' 'NF>1{ sub(/ .*/,"",$NF); print $NF }' | sort | uniq)
all_deps+=$deps
done
printf '%s\n' "${all_deps[@]}" | sort | uniq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment