A file name that I am receiving has 3 parts to it.
- Prefix: foobar_
- date: 2015-12-31_
- filenum: 100.dat
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:
- foobar_2016-02-01_101.dat, or
- foobar_2016-01-30_101.dat, or
- foobar_2016-02-02_101.dat?
and evaluate foobar_2016-02-01_102.dat to false?
Aucun commentaire:
Enregistrer un commentaire