Score:0

How to merge many files together?

za flag

I have around 58,000 txt files that have the prefix ppdb- in a directory. I want to merge all of them into one file.
Wgen I try to merge them using cat ppdb-* >> out.txt it gives me an error saying "-bash: /usr/bin/cat: Argument list too long".
Is there a way to merge all the files together efficiently?

Gounou avatar
us flag
Have a look at [Cannot merge files using cat ; Argument list too long](https://unix.stackexchange.com/questions/167137/cannot-merge-files-using-cat)
mchid avatar
bo flag
This answer is covered by this similar question with the same bash error: https://askubuntu.com/a/949552/167115
Gounou avatar
us flag
_Is there a way to merge all the files together efficiently?_ Your question is not a duplicate of the link a give. Maybe there is a way of doing the concatenation more efficiently (the two answers use `cat`).
Score:2
it flag

Read man find xargs and do something like: (UNTESTED, remove echo when your tests succeed)

find . -maxdepth 1 -name 'ppdb-*' -print0 |\
  xargs -0 -r echo cat >out.txt
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.