Skip to content
Advertisement

Combine 3000k txt files into one txt file Linux

I want to combine 3000k txt files in one txt file Tried this:

cat ./data/*.txt >>final1.txt

But this is gives an error

bash: /bin/cat: Argument list too long

How to do this

Advertisement

Answer

You can use find for that:

find ./data/ -name "*.txt" -exec cat "{}" ; >>final1.txt

* expansion has limits because bash expands it into every single filename and arguments are limited by kernel setting MAX_ARGS_PAGES (see http://www.linuxjournal.com/article/6060)

Advertisement