#!/bin/bash set -e # Define errors and exit codes E_NO_DEBIAN=1 E_MSGS[$E_NO_DEBIAN]="No debian-based distribution" function safe_exit () { local CODE="$1" MSG=${E_MSGS[$CODE]} if [ -z "$MSG" ]; then cat <<-EOF Undefined exit message. Please inform $(basename $0) developer to update his program to use error codes EOF else echo $MSG fi exit $CODE } if [ ! -e /etc/debian_version ]; then safe_exit $E_NO_DEBIAN fi for PKG in $(dpkg --get-selections | grep -E '(install)$' | awk '{print $1}') do [ -z "$(apt-cache show "$PKG" | grep '^Filename: ')" ] && echo "$PKG" done