I have n number of files, I have stored filenames in a list and I want to combine them. I am doing this manually, i.e. If n=3
cat ${filename[1]} ${filename[2]} ${filename[3]} > newfile
If the content of the file is as follows:
filename[1]:
line1
line2
filename[2]:
line3
line4
filename[3]:
line5
line6
I want the newfile to have
newfile:
line1
line2
line3
line4
line5
line6
How can I do this automatically, i.e. for any number of files "n", I want to combine them sequentially as I am doing here for three files manually