I\'m trying to concat a var (date) and string to have a file with current date name.
My code.
days=\"$(date +\"%Y%m%d_%H%M\")\"
echo \"SKIP\" > ${
I guess your vi will have made the entire file DOS-style and so there will be another carriage return at the end of the echo statement
Try dos2unix or using an editor that allows you to change the line-ending style or
sed -i "s/$( printf '\015' )//g" yourscript
try to remove the redundant double quote in your first variable assignment.
$ days=$(date +%Y%m%d_%H%M)
$ echo $days #see what output will get?
$ echo "SKIP" > ${days}_EMERGENCY.txt
It works on my system (OS X) even with double quotes everywhere. For variation I used:
$> days="$(date +'%Y%m%d_%H%M')"
$> echo $days
20160601_1051
$> echo "SKIP" > ${days}_EMERGENCY.txt
$> ll ${days}_EMERGENCY.txt
-rw-r--r-- 1 user team 5 Jun 1 10:52 20160601_1051_EMERGENCY.txt