Created
October 14, 2013 22:47
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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