6

I've seen a couple posts for this, like this one, but none are helping me in my particular situation.

scriptsPath="/var/db/gbi/scripts/"
echo "$scriptsPathawesome.csv";

I would expect this to echo /var/db/gbi/scripts/awesome.csv

Instead I get .csv

Seems like it thinks I'm trying to reference a variable named $scriptsPathawesome. How can I concatenate the $scriptsPath variable to the "awesome.csv" string literal?

Community
  • 1
  • 1
Nick Rolando
  • 25,879
  • 13
  • 79
  • 119

1 Answers1

11

You need to surround your variable with curly braces like so:

scriptsPath="/var/db/gbi/scripts/"
echo "${scriptsPath}awesome.csv";
Alfred Fazio
  • 956
  • 7
  • 10
  • 4
    I would also (or instead) use an explicit path separator, to make it clearer. `$scriptsPath/awesome.csv` is safe, since multiple consecutive separators are treated as a single instance. – chepner Jul 18 '13 at 16:54