Featured image of post Argument too long for operation of many files

Argument too long for operation of many files

I encountered several times when trying to cp/rm/cat >10000 files on Mac. Just a note for the solutions.

There is a very useful post to find and overcome the line length limitations. As written there are two solutions:

  • using the find or xargs command
  • using a loop

For instance I have >10000 files to concatenate and I cannot use

1
2
cat Smp*counts.txt > bigFile.txt
rm -f Smp*counts.txt

Instead I can use

1
2
3
4
find . -name "Smp*-bTcounts.txt" -exec cat '{}' ';'|sort >bT-colCounts.txt
find . -name "Smp*-bTcounts.txt" -delete
# or 
echo Smp*-bTcounts.txt | xargs /bin/rm -f
comments powered by Disqus
CC-BY-NC 4.0
Built with Hugo Theme Stack