Let's say I have a folder named /folder1/ with the following files:
file.txt
log-2018-01-22.log
log-2018-01-21.log
log-2018-01-20.log
I want to move to /folder2/ all files that aren't a .log with the current date, except file.txt. Since today is 2018-01-22 (in my timezone), I want to keep only log-2018-01-22.log and file.txt in /folder1.
The script that I'm using (seen below) doesn't keep file.txt in /folder1/, like I intend to, instead considering it as one of the files that aren't a .log with the current date and moving it to /folder2/.
shopt -s extglob
currentDate=$(date +"%Y-%m-%d")
mv /folder1/!(*$currentDate.log) /folder2/
Is there anything I can change in the !($d.log) part to make the command ignore file.txt?
I suggest: