Dear Unix users I have for example 6 folders and in each folder I have a file called file.txt. The name of the file is exactly the same in all the folders I have. I would like to move all the files called file.txt from each of the 6 folders into a general folder that will contain all the files because I would like to concatenate the files finally. How this can be done?
Input:
folder1: file.txt, folder2: file.txt, folder3: file.txt
Output:
final_folder: file.txt, file.txt, file.txt
Thanks
Eleonora
You cannot have multiple files with the same name within the same directory. If you’re planning to eventually concatenate all the files, while not just do it all at once?
For example, the following command will concatenate all
file.txtfiles within directories with names that start withfolderand write the output tonew_file.txt:If you want to include files within multi-level subdirectories, you can consider using
find.The following will recursively search for
file.txtwithin the current directory (and all subdirectories) and concatenate their contents intonew_file.txt.