79167424

Date: 2024-11-07 17:09:22
Score: 1
Natty:
Report link

For accessing the environment variable in a readable way, I'd make a shell function of it:

getenv() { 
    awk 'BEGIN {print ENVIRON[ARGV[1]]}' "$1";
}

You can then use it as

$ getenv agent1.ip
192.168.100.137
$ myvar=$(getenv agent1.ip)
$ echo "$myvar"
192.168.100.137

Differences with the accepted answer are:

There is also another question about Exporting a variable with dot (.) in it.
Short answer: you can't, but you needn't, except for calling another executable. In that case use env.

Reasons:
  • Blacklisted phrase (1): another question
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Filip B.