#!/bin/bash
html='/opt/websites/nav/index.html'
jpg_max_num=`cat $html | grep -oE "[0-9]+\.jpg" | awk -F '.' '{print $1}' | sort -n | tail -n 1`
line_num=`cat $html | grep -oE "[0-9]+\.jpg" | awk -F '.' '{print $1}' | sort -n | uniq -c | wc -l`
jpg_all_num=`ls -al /opt/websites/nav/assets/images/logos/ | wc -l`
if [[ $((jpg_max_num+1)) -ne $line_num ]]; then
echo -e "\e[1;31mThere must be duplicated jpg files, plz check!\e[0m"
return 2
fi
echo "Now: $jpg_max_num | MAX: $jpg_all_num | AVAILABLE: $((jpg_all_num-jpg_max_num)) | NEXT: $((jpg_max_num+1))"