I need to output an array to a file in the following format.
File: a.txt
b.txt
I tried doing the following :
declare -a files=("a.txt" "b.txt")
empty=""
printf "File:" >> files.txt
for i in "${files[@]}"
do
printf "%-7s %-30s \n" "$empty" "$i" >> files.txt
done
But, I get the output as
File: a.txt
b.txt
Can anyone please help me to get the output in the required format.