Hello,
I need to read files from /dest directory and delete those files that are not present in /origin directory.
i.e :
1/ Read files from /dest directory
2/ If the read files don't exist on /origin directory Then delete the read file from /dest directory
Thx,
zaxxon
2
What did you try so far? Where are you stuck?
Hmm. Why not use rsync?
...actually read to much into this as I assumed a remote server....
create a little shell script:
cd /dest
for file in * ; do
if [[ ! -f $file ]]; then
continue
fi
if [[ ! -f /origin/$file ]]; then
echo /bin/rm $file
fi
done
I used an echo so you can test the script without nuking things accidentally.
Once you're happy with it, pipe it to ksh to make it actually nuke the files.
ie:
test:
my_rm_script.sh
fire:
my_rm_script.sh | ksh