I'm starving trying to make the following thing work:
#!/bin/bash
MARCOMIN=1
MARCOMAX=3
ENZOMIN=1
ENZOMAX=3
GIOVANNIMIN=1
GIOVANNIMAX=3
VALUEMARCO=12
VALUEGIOVANNI=4
VALUEENZO=12
for i in MARCO ENZO GIOVANNI; do
echo $$iMIN is $i\'s MIN
echo $$iMAX is $i\'s MAX
echo $VALUE$i is $i\'s VALUE
done
exit 0
It doesn't writes macro as I'd like, though.
me@myhost:~$ bash test.sh
20341iMIN is MARCO's MIN
20341iMAX is MARCO's MAX
MARCO is MARCO's VALUE
20341iMIN is ENZO's MIN
20341iMAX is ENZO's MAX
ENZO is ENZO's VALUE
20341iMIN is GIOVANNI's MIN
20341iMAX is GIOVANNI's MAX
GIOVANNI is GIOVANNI's VALUE
Obviously this is only one of my test. I tried many different ways of writing macros this way but I can't fix it. Found many similar questions here and on SO, but none matched my case.
bash -x test.sh
follows:
+ MARCOMIN=1
+ MARCOMAX=3
+ ENZOMIN=1
+ ENZOMAX=3
+ GIOVANNIMIN=1
+ GIOVANNIMAX=3
+ VALUEMARCO=12
+ VALUEGIOVANNI=4
+ VALUEENZO=12
+ for i in MARCO ENZO GIOVANNI
+ echo 21466iMIN is 'MARCO'\''s' MIN
21466iMIN is MARCO's MIN
+ echo 21466iMAX is 'MARCO'\''s' MAX
21466iMAX is MARCO's MAX
+ echo MARCO is 'MARCO'\''s' VALUE
MARCO is MARCO's VALUE
+ for i in MARCO ENZO GIOVANNI
+ echo 21466iMIN is 'ENZO'\''s' MIN
21466iMIN is ENZO's MIN
+ echo 21466iMAX is 'ENZO'\''s' MAX
21466iMAX is ENZO's MAX
+ echo ENZO is 'ENZO'\''s' VALUE
ENZO is ENZO's VALUE
+ for i in MARCO ENZO GIOVANNI
+ echo 21466iMIN is 'GIOVANNI'\''s' MIN
21466iMIN is GIOVANNI's MIN
+ echo 21466iMAX is 'GIOVANNI'\''s' MAX
21466iMAX is GIOVANNI's MAX
+ echo GIOVANNI is 'GIOVANNI'\''s' VALUE
GIOVANNI is GIOVANNI's VALUE
+ exit 0
$$
expands to the PID of the running process, which is why you're seeing those numerical prefixes. If you want to do what it is you appear to be trying for, you might have to look into usingeval
. – DopeGhoti Aug 24 '17 at 19:32