Reputation: 1854
I am trying to concatenate 2 variables into a string in Bash. I have seen a lot of posts on this and for some reason they don't work for me. Here is my script which just takes a file name prefix and adds the current date to the end.
#!/bin/bash
now=$(date +”%Y%m%d”)
fname=“file”
x=$fname$now
echo $x
This results in "file""20150316"
instead of the desired "file20150316"
.
Please help. Thanks.
Upvotes: 2
Views: 2438
Reputation: 785058
You're using wrong quotes (unicode ones not the actual ASCII ones). Try this:
#!/bin/bash
now=$(date "+%Y%m%d")
fname="file"
x="$fname$now"
echo "$x"
Upvotes: 4