Forked from jameshfisher/restore-file-from-package.sh
Last active
August 29, 2015 14:18
-
-
Save dragon788/e32afca5adc0f7beb636 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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