I have a simple if-statement that checks if a file exists in a directory. If it matches it returns OK, otherwise, it echos FAIL.
if [[ -f Foobarfile_"${TODAY}"*.txt ]]; then echo "OK"; else echo "Fail!"; fi
$TODAY
is a date stamp having YYYY-MM-DD format.
If I have in the directory Foobarfile_2016-01-15_100.txt" as the only file, the if-statement will return true.
I am puzzled because if the directory has multiple files, the if-statement will return false. E.g. if it has another file called "Foobarfile_2016-01-15_101.txt"
It should basically check that as long as the directory has a filename that has today's date stamp, i.e.:
Foobarfile_2016-01-15_100.txt
Foobarfile_2016-01-15_101.txt
somethingelse_2016-01-15_102.txt
KrispyKreme_2016-01-14_98.txt
Foobarfile_2016-01-15_104.txt...
it should return true. Can anyone help with this problem?