I am working in bash (Fedora). I have a list of text files as follows:
filenameA filename1
filenameA filename2
filenameA filename3
filenameB filename4
filenameB filename5
I wish to combine (cat) all of the files listed in second column with their match in the first column like this:
cat filenameA filename1 filename2 filename3 > newfilenameA
cat filenameB filename4 filename5 > newfilenameB
Is there a 'while' or 'for' loop that can accomplish this for a longer list of files? I want the file contents to be combined, not just a list of file names.