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" > ${days}_EMERGENCY.txt
but when I run, I get a file with a ? in file name, like this:

Am I doing something wrong?
EDIT
Looking at symbol, ? stands for \r - could it be because I'm writing on notepad and then upload via ftp the .sh script?
EDIT 2
Tried with vi on local machine - now it's also worse.

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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With