#!/usr/bin/env bash # files is an array of filename:destination. Filename is the name of # the file in this directory that is to be copied, and destination is # the destination for that file, relative to the users home dir # /home/$USER/. files=("gitconfig:.gitconfig" "procmailrc:.procmailrc") files=("${files[@]}" "vimrc:.vimrc" "Xdefaults:.Xdefaults") for arg in "$@"; do match=1 for str in "${files[@]}"; do filename="${str%:*}" destination="/home/$USER/${str#*:}" if [ "$arg" == "$filename" ]; then match=0 echo "cp $filename $destination" cp $filename $destination fi done if [ $match -ne 0 ]; then echo "Could not find rule for file $arg">&2 fi done