Sample Header Ad - 728x90

Bash nested variable

0 votes
1 answer
67 views
I source these variables from a txt file in CentOS bash shell:
NAME01=dns1
HOST01=1.1.1.1
NAME02=dns2
HOST02=1.1.2.2
NAME03=dns3
HOST03=1.1.2.3
## many more lines of similar

NUM=02
How can I use $HOST$NUM to give me 1.1.2.2, such as:
echo $HOST$NUM
Asked by SmplJohn (11 rep)
Sep 5, 2024, 06:54 AM
Last activity: Sep 7, 2024, 08:09 PM