I needed some script to take care of my config files and put them in a single directory. So here it is.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
#!/bin/bash # Display All Hidden Dot Files In a Directory # ls -a | egrep "^\." > backup_dotfiles.sh DESTINATION="/storage/dotfiles" # do not use a trailing slash (/) # Colors blue="\e[0;34m" green="\e[1;32m" red="\e[0;31m" bold="\e[1;30m" reset="\e[0m" # file list (use trailing slash for directories) FILES=" .bash_aliases .bash_logout .bash_profile .bashrc .colours/ .config/openbox/ .config/terminator/ .config/tint2/ .config/zathura/ .devilspie/ .fehbg .fonts.conf .gtk-bookmarks .gtkrc-2.0 .gtkrc-2.0.mine .inputrc .mplayer/ .nanorc .rtorrent.rc .screenrc .synergy.conf .vim/colors/ .vimrc .xbindkeysrc .Xdefaults .xinitrc .xmod .Xmodmap .xsession .xxkb/ .xxkbrc " for file in $FILES do if [ -d $file ]; then mkdir -p $DESTINATION/$file cp -f $HOME/$file* $DESTINATION/$file elif [ -f $file ]; then cp -f $HOME/$file $DESTINATION else echo -e "$red:: $file is not a file/directory! $reset" fi done echo -e "$green:: Done! $reset" exit 0 |
Thanks for this, it was really useful and easy to understand. 🙂