Can anybody write script, which can make copy of some or all files of the current directory in new directory (called "backups", which must be made in the current directory, if it's not already exist). And bring out a massage (report) with the count of the successfull copied files.
Yeah, it doesn't take much to learn this kind of stuff (at least for what you want to do).. but I did make a very basic script to do it.
#!/bin/bash
tempfile="temp`date +%Y-%m-%d`.log"
if [ ! -d "./backups" ] ; then
mkdir backups
fi
for file in `find . -type f -maxdepth 1`; do
cp --reply=no -v $file ./backups/ >> $tempfile
done
filecount=$(cat $tempfile | wc -l);
rm -f $tempfile
echo "Backup Complete.";
echo "Successfully copied $filecount files to ./backups";
It checks to see if ./backups is a directory and if not, then creates a directory named backups/ . Then it goes through a loop for all files in the current directory and puts them in backups/ , but will automatically say "no" to overwriting files that already exist in that directory with the same name.
It will report how many files were successfully copied.
I do agree with zaxxon however, and you should learn it. But I am bored, and stuff.. Anything else?
(10) Don't post your email address and ask for an email reply. Don't send a private message with a technical question. The forums are for the benefit of all, so all Q&A should take place in the forums.
I apologize. I wasn't saying to message me so I could answer any technical questions. I was merely saying that I could keep modifying the script. I will keep it in the forums though.