I have a file with a bunch of variables such as:
file
DEVICE0_USB="usbSerialNo1"
DEVICE1_USB="usbSerialNo2"
and I want to assign the contents of any of these variables to variables in a script, for instance:
script
FAX_MACHINE_USB=$DEVICE0_USB
COFFEE_MAKER_USB=$DEVICE1_USB
so that when I echo
$FAX_MACHINE_USB
I receive usbSerialNo1
I can use source
to get the variables from file but this will also run every line in file. In my case it's not a problem since file has only variable declarations, but I still prefer not to do it. Is there another way of achieving it?
file
to replace the variables inscript
without executingfile
following this question and answer – Philippos Aug 25 '17 at 16:21FAX_MACHINE_USB="$DEVICE0_USB"
. – Chris Davies Aug 25 '17 at 18:22