I'm new to unix/bash/code in general, and I'm trying to merge multiple sample files with the same name in different directories into a new file in its own directory (the outputs of multiple data collections).
To do this, I'm trying to create a script which uses two arrays - listA, the name of each sample file, and list B, the names for the newly merged sample files.
My code looks a little like this:
#!/bin/sh listA=( old1 old2 old3 etc.) listB=( new1 new2 new3 etc.) i=0 for i in $listA $listB do cp ./folder1/$listA ./merged/$listB cat ./folder2/$listA >> ./merged/$listB cat ./folder3/$listA >> ./merged/$listB cat ./folder4/$listA >> ./merged/$listB ((i=+1)) done echo "Done stitching"
As is, it seems to merge the files for the first entry in listA into the first file in listB perfectly, but it won't repeat the process for the subsequent entries on the list.
Any advice to make this work as intended? Apologies for my ignorance, I'm very new to all of this and enjoying the learning process immensely - just a bit stumped.