Reputation: 9189
I'm writing a shell script on MacOSX for the first time, and I'm a little stuck. I'm creating a website, and wanted a simple way to manage updating my files from my git repo to the localhost server. It's also just an excuse to learn shell scripting. Here's what I have so far:
#!/bin/bash
echo "Removing old Files..."
rm -r /Library/WebServer/Documents/ServerObserver/*
echo "Copying new Files to WebServer"
cp -r /Users/ajay/Documents/ServerObserverRepo/* /WebServer/Documents/ServerObserver/
echo "Done!"
The removing part works fine, but copying does not work. I get this message in my Terminal:
usage: cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file target_file
cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file ... target_directory
Of course, it didn't copy either. Any help would be appreciated!
Thanks!
~Carpetfizz
Upvotes: 0
Views: 3808
Reputation: 3877
You should consider rsync, as in
rsync --delete -a /Users/ajay/Documents/ServerObserverRepo/ /WebServer/Documents/ServerObserver/
that removes the need for the rm command and the cp command, and only copies the changed files / removes the deleted ones. :)
Upvotes: 1
Reputation: 8881
change
cp -r /Users/ajay/Documents/ServerObserverRepo/* /WebServer/Documents/ServerObserver/
to
cp -r /Users/ajay/Documents/ServerObserverRepo/* /WebServer/Documents/ServerObserver/.
Upvotes: 1