Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dragon788/e32afca5adc0f7beb636 to your computer and use it in GitHub Desktop.
Save dragon788/e32afca5adc0f7beb636 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Usage:
#
# sudo ./restore-file-from-package.sh <filepath>
#
# Restore a file from the package that provides it.
#
# Source: http://askubuntu.com/a/67028/30482
# using --force-confask instead of confmiss to
# merge if partially customized file is present
set -x
set -e
FILE_TO_RESTORE=$(readlink -e $1)
mv -n ${FILE_TO_RESTORE} ${FILE_TO_RESTORE}.bak
apt-get -o Dpkg::Options::="--force-confask" install --reinstall $(dpkg -S ${FILE_TO_RESTORE} | head -1 | cut -d ':' -f1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment