I'm trying to create a script which searches for particular errors in a logfile. The logfile is date stamped so I want to check just todays log file. This will end up as a cronjob. When I run this. I currently get the below error:

> 
> tail: cannot open `/var/log/file.2014-09-03-Wed\n.log' for reading: No
>  such file or directory
> 
> 
> 

So I get the date, but then there's a \n which is added. Script below:

```
$date=`date +"%Y-%m-%d-%a"`;
$string = `tail -n50 /var/log/"file.$date.log" | grep -B2 'Too many connected clients'`;

if($string =~ m/Reply: 421 Service not available. There are too many connected users, please try later/){
print "Max connections reached $date"
}

```

Any advice would be greatly appreciated!