Skip to content

Instantly share code, notes, and snippets.

@cebe
Created October 22, 2014 20:21
Show Gist options
  • Save cebe/a220c8a9b6783503c407 to your computer and use it in GitHub Desktop.
Save cebe/a220c8a9b6783503c407 to your computer and use it in GitHub Desktop.
variable name in shell misinterpreted.
#!/bin/sh
FOO="test"
BAR="123"
VAR="$FOO_$BAR"
# result is "123" instead of "test_123" because _ is seen as part of the var.
# how can I fix this?
@cebe
Copy link
Author

cebe commented Oct 22, 2014

turns out the solution is VAR="${FOO}_${BAR}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment