You can do this by listing both sets of packages and determining the difference between the two results:
grep -Fxv -f <(apt list | grep unstable | cut -d/ -f1) <(apt list | grep experimental | cut -d/ -f1)
This produces “experimental minus unstable”, and can be adapted to calculate any difference by changing
experimental. Strictly speaking it matches more than just the suite; the following variant matches exactly by matching only after the
apt list’s output:
grep -Fxv -f <(apt list | egrep /.\*unstable | cut -d/ -f1) <(apt list | grep /.\*experimental | cut -d/ -f1)
(Otherwise packages with “experimental” in their name appear when they shouldn’t, for example when comparing testing and experimental,
trafficserver-experimental-plugins is listed even though it’s only present in unstable.)
apt list only lists candidate packages by default, so to get the correct results especially when comparing testing and unstable you need to do:
grep -Fxv -f <(apt list --all-versions | egrep /.\*unstable | cut -d/ -f1) <(apt list --all-versions | grep /.\*experimental | cut -d/ -f1)
cuts extract the package name from
apt’s output. The first set of packages (from unstable) is given as a list of patterns for
grep using the
grep to consider the patterns as plain text strings rather than regular expressions;
-x tells it to match each pattern completely; and
-v tells it to list lines which don’t match the given patterns.
grep takes all the packages in experimental, keeps only those which aren't in the list of packages from unstable, and outputs the result.
<() constructs use process substitution to feed the standard output of the commands contained within the brackets to a pipe which can then be used as input for another command; see the advanced bash guide for details.