Skip to content

Instantly share code, notes, and snippets.

@texadactyl
Last active August 28, 2016 19:30
Show Gist options
  • Save texadactyl/4d841712580ce47f9f2d to your computer and use it in GitHub Desktop.
Save texadactyl/4d841712580ce47f9f2d to your computer and use it in GitHub Desktop.
Given an installed Ubuntu file, what Ubuntu package does the file belong to?
MYSELF=`basename $0`
ARG=$1
ARGC=$#
if [ $ARGC -lt 1 ] || [ -z $ARG ]; then
echo
echo -e "\tUsage:\t"$MYSELF"\t{Installed File(s)}"
echo
exit 86
fi
for ARG in $*; do
dpkg -S "$(readlink -fn "$(which $ARG)")"
done
exit 0
####################################################
# Example:
# file2pkg.sh ls
# Standard output:
# coreutils: /bin/ls
# For this example,
# coreutils is the derived package name.
# /bin/ls is the full path of the argument file.
####################################################
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment