Mike F
Mike F

Reputation: 111

combine contents of files from multiple directories into a single text file in Mac OSx

I have a complicated scenario. In my current working directory, I have several subdirectories. Each subdirectory has a number of files, but I'm only interested in one: RAxML_bestTree.best. The file name is the same for each corresponding file in every subdirectory, i.e., they are not unique. Thus, a copy command to a new subdirectory will not work since one RAxML_bestTree.best will be shown and overwritten 514 times.

I need to take the content of each subdirectory's RAxML_bestTree.best and have it placed into a file all_RAxML_bestTrees.txt either in the current working directory or a new subdirectory. I have tried the following, which appears to print the contents to screen but not to file:

find . -type f -name \RAxML_bestTree.best -exec cat {} all_RAxML_bestTrees.txt \;

Upvotes: 0

Views: 103

Answers (1)

Mike F
Mike F

Reputation: 111

Nevermind, found my issue:

find . -type f -name \RAxML_bestTree.best -exec cat > all_RAxML_bestTrees.txt \;

Upvotes: 1

Related Questions