Skip to content

Instantly share code, notes, and snippets.

@micron
Created October 14, 2013 22:47
Show Gist options
  • Save micron/6983550 to your computer and use it in GitHub Desktop.
Save micron/6983550 to your computer and use it in GitHub Desktop.
A small script for copying config files on an server to the right location
#!/bin/bash
# point to the directory where the config files are stored
CONFIG_DIR="/path/to/your/dir/"
cd $CONFIG_DIR
if [ "$1" == "" ]; then
DIRECTORY=$(ls -al | awk '{print $1,$9}' | grep -i ^\- | awk '{print $2}');
else
# alternatively you can pass a file as the first argument with the files separated by a newline
DIRECTORY="`cat $1`";
fi
# iterate through the files
for f in $DIRECTORY
do
if [ "$f" == ".htaccess" ]; then
cp $f ../web/;
echo "Copying $f to destination.";
fi
if [ "$f" == "site.php" ]; then
cp $f ../web/config/;
echo "Copying $f to destination.";
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment