Friday, November 01, 2013

Make a backup of your dotfiles

If you are a regular Linux user, chances are you change distros to experiment with them. I am one of such persons who like to experiment with various Linux distros for both educational and experimental reasons. This activity may sometimes lead to problems regarding your Desktop Environment (DE) and others. It also might be the case that you just want to clean up your /home but keep your configurations intact using your dotfiles (The directories and files in your /home whose name start with a '.'). Moving these files manually is cumbersome (at least for me). The following script does it for me. And moves it to a folder called "dotfiles" in your ~/.
CAUTION: It removes any folder called 'dotfiles" in you ~/ and creates a new one.
You MUST run this in your ~/
rm -rf dotfiles
mkdir dotfiles
while read line; do
        if [ "$line" = "" ]; then
                continue
        fi
        if [ -d "$PWD/$line" ]; then
                echo "$PWD/$line is a folder"
                cp $PWD/$line $PWD/dotfiles/$line # substitute cp with mv to move the files
        else
                echo "$PWD/$line is a file"
                cp $PWD/$line $PWD/dotfiles/$line # substitute cp with mv to move the files
        fi
done < <(find . -maxdepth 1 -name ".*" -printf '%P\n')

No comments:

Post a Comment

Post your comment here. If you want to say something about programming problems, scripts, software etc, please try to be as descriptive as possible.

Connect Rapoo MT750S with Linux (Tested on Manjaro)

 I bought this obvious copy of MX Master 2S in hopes of having the device switching functionality along with a lightweight body because I ha...