Warm tip: This article is reproduced from stackoverflow.com, please click
bash shell

Append an environment variable to another one with export

发布于 2020-03-29 21:01:05

I want to append a previously exported string to a new one, so that:

export TAG=img
export FILENAME=$TAG_001.jpg

The result I'd like to obtain is $FILENAME=img_001.jpg, but the export processes it as $TAG_001 instead of $TAG

Questioner
EUS
Viewed
61
YOU 2020-01-31 18:37

Try

export FILENAME=${TAG}_001.jpg