I have an array in which every element may contain another variable. The array assignment is from a file as follows:
FILE_CLEANUP_DIR_ARR=($(cat cleanup.list | sed '/^[[:blank:]]*$/d' | sed '/^[#]/d'))
How can I restore the aray with the expanded variables.
TARGET_DIR=/SOMEROOTDIR
FILE_CLEANUP_DIR_ARR[0]
has value literally as $TARGET_DIR/SOMESUBDIR0
FILE_CLEANUP_DIR_ARR[1]
has value literally as $TARGET_DIR/SOMESUBDIR1
How can I restore this FILE_CLEANUP_DIR_ARR to expanded variables as follows.
FILE_CLEANUP_DIR_ARR[0] = /SOMEROOTDIR/SOMESUBDIR0
FILE_CLEANUP_DIR_ARR[1] = /SOMEROOTDIR/SOMESUBDIR1
Sample code. Not working.
i=0
for CDIR in "${FILE_CLEANUP_DIR_ARR[@]}";
do
FILE_CLEANUP_DIR_ARR[i]="$CDIR"
((i++))
done
FILE_CLEANUP_DIR_ARR=($(cat cleanup.list | sed '/^[[:blank:]]*$/d' | sed '/^[#]/d'))
– Srinivasarao Kotipatruni Aug 22 '19 at 14:23