Hi all,
I am fairly new to shell scripting and I am trying the following:
My shell script creates a tar file with files with the ending ~. The directory - where the files and sub directories are located - comes as a parameter when I call the script. Files that are archived will be written in a log /var/log/ttl.log and files that have been archived shall be deleted. Deleted files shall also be written in the log under /var/log/ttl.log. Files with the ending ~ in sub directories shall not be deleted. I hope this makes sense.
What I have so far:
#!/bin/bash
args="$1/"
if [ $# -eq 0 ]
then
echo "$(date) no parameter specified" >> /var/log/ttl.log
exit;
else
if [ -d $1 ]
then
find $args -type f -name "*~" -print | xargs tar rvf /home/scripte/something.tar >> /var/log/ttl.log --remove-file
else
echo "$(date) no valid directory given" >> /var/log/ttl.log
exit;
fi
fi
This works, but the files are not deleted . Can someone point me in the right direction please?
Another thing: How would I go about deleting the files in the sub directories as well as a next step of my script?
Help is very much appreciated.
Thanks a bunch
EDIT: got it - thread closed