I have a script to tar up some older files. It did a find and mv, but I had to change it to preserve the directory structure because some of the directories now have duplicate nameed files. I changed it to a find and copy, then added a find and remove.
Is there a better way so I don't have to do 2 finds? I tried to do the tar in the find, but it ignored the directory structure and overlaid the duplicate named files.
/opt/applic/AAA/logs/ and /opt/applic/BBB/logs/ each have a file called output.log
TARGETDIR=/opt/applic//logs/
# WORKDIR/REF is a reference file dated to be the oldest file we will keep
find $TARGETDIR/ -type f -maxdepth 1 -iname \*.log\ ! -newer $WORKDIR/$REF -exec cp -p --parents {} $WORKDIR \;
find $TARGETDIR/ -type f -maxdepth 1 -iname \*.log\* ! -newer $WORKDIR/$REF -exec rm -f {} \;
tar cvf ARCH/logs_xyz.tar $WORKDIR