This question already has an answer here:
I am creating a logfile from kermit named the current date (which is in the format of DD MMM YYYY - which can not be changed AFAIK), and using the file name as today's date.
I then have a Bash script to read the file and I want to
tail -n1 the file.
if I do
filename=$(date +%d\ %b\ %Y) && echo $filename
23 Feb 2015
which is what I want and expect. However if I then do
filename=$(date +%d\ %b\ %Y) && tail -n1 $filename
tail: cannot open `23' for reading: No such file or directory tail: cannot open `Feb' for reading: No such file or directory tail: cannot open `2015' for reading: No such file or directory
I am not sure what is causing this, probably down to the the way I have string formatted I guess since I get the same if I use