Duplicate lines in multiple files within folders (Argument list too long)

Hi,

So I'm trying to find duplicate lines on a repertory that contains multiple files
the test of the command below is working on a folder with a little number of files :
grep -T -r . mainfolder | sort -k 2 | uniq -D -f 1

But my problem is that the reel test is a folder with 500000 files and the massage :
Argument list too long

Is there a way to do it please ?

Best Regards

Welcome!

Your given command cannot yield a "Argument list too long" error, because the arguments are fixed:
-T -r . mainfolder (4)
-k 2 (2)
-D -f 1 (3)
Please give the full command!

2 Likes

Hi,
Thank You!

I'm using : grep -T -r . * | sort -k 2 | uniq -D -f 1

as you can see, on screen shot below, I used it on a repertory with 46 files and I had the result
And used it on a repertory with more than 500000 files and I have the massage: argument too long

Aha, the * expands to too many arguments (filenames).
Try with . instead:

grep -T -r . . | sort -k 2 | uniq -D -f 1
1 Like

The op originally asked to list the duplicated lines.
A clarification question for them...
Are the dupes -

  1. Within a single file
  2. Within a single directory
  3. Within the entire find results list.
    Code should be enhanced to meet that expectation...
1 Like