Problem with " Argument list is long"
1
0
Entering edit mode
6.1 years ago

I am facing a problem with concatenating file with cat command as I have to concatenate120441 files together. In test directory, I have 120441 subdirectories which start with GC and every subdirectory contain a result_tab.txt file which I need to concatenate. I use the following command cd test cat GC*/result_tab.txt > result_all.txt

But error occurs " Argument list is too long". Then I use the following command

find  . -name 'result_tab.txt' -exec cat {} + > result_all.txt

But when I see the result_all.txt file there is nothing. Any solution? I tried the following for loop too. But not working

for f in GC*/result_tab.txt; do cat "$f"; done > results_all.txt
sequence • 1.1k views
ADD COMMENT
0
Entering edit mode
6.1 years ago
h.mon 35k

Even as I question myself about the usefulness of concatenating 120441 "result_tab.txt" into one, here is one solution:

 find  . -name 'result_tab.txt' -exec cat {} \; >> results_all.txt

Here is another, with a loop:

for i in GC*/result_tab.txt; do cat "$i" >> results_all.txt; done

Make sure "results_all.txt" does not exist, otherwise output would be appended to the already existing file.

ADD COMMENT

Login before adding your answer.

Traffic: 1259 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6