Skip to content

Instantly share code, notes, and snippets.

@phunehehe
Created February 25, 2011 04:54
Show Gist options
  • Save phunehehe/843374 to your computer and use it in GitHub Desktop.
Save phunehehe/843374 to your computer and use it in GitHub Desktop.
In Gentoo, after updating you may see the message "IMPORTANT: <number> config files in '/etc' need updating.". This script looks for all the files that need to be updated, then overwrite old config files with new ones. Useful when there are a lot of new c
#! /bin/sh
# Update: There is no point using this, we have `etc-update'
for new_config in $(find /etc/ -name '._cfg????_*')
do
old_config=$(echo $new_config | sed 's:\([a-zA-Z0-9]*\)\._cfg[0-9]\{4\}_\([a-zA-Z0-9]*\):\1\2:')
if [[ -f "$new_config" || -f "$old_config" ]]
then
mv $new_config $old_config
else
echo "Something is wrong with $new_config ."
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment