I have a few files whose names I have assigned into variables. (There may be n number of files). Those variables are passed into an array. Now I want to print the names of the original files using that array.
Since there can be n number of files, I cannot make a static list of file names. I need to make a tar of every file. In one case, there can be only 1 file, in other, there can be 2 or 3 or 4 files. So I am creating a generic script for this purpose.
export count=2
testlist0=abc
testlist1=notabc
declare -a testlist_array[$count]
for ((i=0;i<${count};i++));
do
testlist_array[$i]=testlist$i
done
echo ${testlist_array[@]}
But it is not printing the file names abc not abc.
var="testlist$i";testlist_array[$i]="${!var}"