#!/bin/bash
FILES=*.zip
comparer=""
for f in $FILES
do
a="${f%.*}"
b=`echo $a|awk -F "_" '{print $3}'|awk -F "." '{print $1}'`
if [ "$comparer" == "" ]; then
comparer=$b
continue
fi
if [ $(date -d $b +"%Y%m%d") -lt $(date -d $comparer +"%Y%m%d") ]; then
echo "File name containing $b is older than the file containing $comparer. Keeping the file containing $comparer and deleting the file containing $b. "
# rm *$b*.zip
elif [ $(date -d $b +"%Y%m%d") -eq $(date -d $comparer +"%Y%m%d") ]; then
echo "Cannot decide which one is newer for ending with $b"
else
echo "File name containing $b is newer than the file containing $comparer. Keeping the file containing $b and deleting the file containing $comparer."
# rm *$comparer*.zip
comparer=$b
fi
done
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE