if [[ $file =~ "02\\-[0-9]\{2\}-2015" ]]; then cp $file /tmp/feb;fi
The problem is the regex is not picked up in this test condition. Can someone help? In addition, I need to make sure that the newline is not printed, the filenames have spaces in them, and that is why IFS='\n' is used.
This is the line that the OP posted having problems with:
if [[ $file =~ "02\\-[0-9]\{2\}-2015" ]];
The intention was to just show where the trouble originate from, thus, basically, the copy and paste.
Otherwise, I would have not even bother with a loop, a simple ls pattern | xargs cp would have done the job.
Since version 3 bash obtained its own regex-match operator: =~.