I have a config file that contains the following line:
pre_args='$REGION','xyz',3
Using perl from within a csh script I can evaluate environment variable $REGION like so:
set pre_args = `grep -v '^#' $config_file | grep pre_args | cut -f 2 -d = | sed 's/ //g'`
if ("$pre_args" != "") then
set pre_args = `echo $pre_args | perl -ne 'use Env; s/(\$\w+)/$1/eeg; print'`
endif
If $REGION = SOUTH, $pre_args is now set to: SOUTH,xyz,3.
Is there a way to do this using the shell's built-in commands and not having to rely on using perl? By the way, the choice to use csh is not mine, so please no replies criticizing that. Thanks.