I have directory containing ~300K text files that I would like to concatenate into a single file, separating the contents of each file using a newline \n
. For example
file1 = 'i like apples'
file2 = 'john likes oranges'
output = 'i like apples\njohn likes oranges'
The problem is that due to the large number of files, commands like
awk '{print}' dir/* combined.txt
throw an error about the list of arguments being too long. Any quick way to get around this issue? I have been trying to find a way to use piping but have been unsuccessful so far.
The text files do not end in a \n
.
parallel
or something equivalent, that would be even better! – Orest XherijaArgument list too long
error. – Orest Xherija-exec
instead". – Benjamin W.