How do you extend variables in UNIX / BASH?

The nested variables prevented me from using BASH more widely ... consider the following:

export SYS_DIR='/home/${LOGNAME}/sys'
export APP_DIR='${SYS_DIR}/app'

I always get

> set
APP_DIR=/home/${LOGNAME}/sys/app

why? lol

and how do I get what I want = /

I am not trying to resolve $ {$ {var}}, but rather the actual lines as shown above

+3
source share
1 answer

Use double quotes

export APP_DIR="${SYS_DIR}/app"

Single quotes treat everything inside as literals, rather than being evaluated.

+10
source

Source: https://habr.com/ru/post/1742587/


All Articles