A file name that I am receiving has 3 parts to it.
Putting them together we get foobar_2015-12-31_100.dat. Currently picking out files with today's date and correct filenum works. So, the next filenum is 101. Please examine script to understand.
echo "Checking for file"
DBNR=`mysql -uroot -p$DBPWD test_schema -sNe 'SELECT max(file_id) FROM filenumbers WHERE filetype="D"'`
echo "Last number is: ${DBNR}"
NEXTNUM=$((DBNR+1))
NEXTFILE="foobar_${TODAY}_${NEXTSEQ}.dat"
echo ">>>>> NEXT FILENAME: ${NEXTFILE}" # $TODAY is optional
if [ -f "${NEXTFILE}" ]; then
echo ">>>>> Correct file exists!"
else echo "Incoming dir is not empty but expected file is not present."
The line where NEXTFILE is is generating for a specific file but comment states $TODAY is optional. How do I then exclude $TODAY so that the if-statement below will evaluate to true for file names:
and evaluate foobar_2016-02-01_102.dat to false?
I believe you can use this check:
if [[ -f foobar_*_${NEXTSEQ}.dat ]]; then
echo ">>>>> Correct file exists!"
else
echo "Incoming dir is not empty but expected file is not present."
fi
*
will make it work for any date in between.