1

Say I have something like this,

tee filename <<EOF
...
access_log /srv/users/serverpilot/log/$APP_NAME/$APP_NAME_nginx.access.log  main;
...
EOF

where $APP_NAME is a variable.

Bash interprets $APP_NAME_nginx as a variable and doesn't print any value there. How could I fix that?

1 Answer 1

1

You need:

${APP_NAME}_nginx

This will make bash expanding the variable APP_NAME to its value and adding _nginx to it.

Here is a test:

$ APP_NAME=check
$ echo "$APP_NAME"
check
$ echo "$APP_NAME_var"

$ echo "${APP_NAME}_var"
check_var
2
  • by the way, how would avoid $something from being interpreted as a variable?
    – autorun
    Apr 10, 2015 at 23:18
  • 1
    Just add a backslash escape at the start \$something
    – heemayl
    Apr 10, 2015 at 23:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .