-1

I am using ZSH, and I believe I need to use variable expansion to solve my problem, but I'm not entirely sure.

FOOFIELD=1
PROPERTY=FOO

echo ${(P)PROPERTYFIELD}

Expected Result: 1

Current Result: null

What am I doing wrong?

27560
  • 93
  • 7

1 Answers1

1

You can achieve this by executing the below commands

➜  ~   FOOFIELD=1
➜  ~   FOO=11
➜  ~   PROPERTY=FOO
➜  ~   echo ${(P)PROPERTY}
11
➜  ~   echo ${${(P)PROPERTY}FIELD}
1
Al-waleed Shihadeh
  • 2,697
  • 2
  • 8
  • 22