James Trory
James Trory

Reputation: 121

/usr/bin/find: Argument list too long

I know this is a common error but I'm really stuck and could use some help.

I need to create an Excel sheet of any files in a subdirectory named Parent, that exists in the root folder Tabletop. This is what I have:

find $(find /Volumes/COMMON-LIC-PHOTO/STUDIO-COMPLETE/ARCHIVE/Tabletop -type d -iname parent | xargs) -type f > Parent_Files_TT.csv

It searches for folders named Parent and then copies the full file path to Excel. This has worked on other smaller folders I have, but Tabletop has hundreds of thousands of files in it and I get the error:

/usr/bin/find: Argument list too long

I have tried to modify this to use xargs when finding the file:

find $(find /Volumes/COMMON-LIC-PHOTO/STUDIO-COMPLETE/ARCHIVE/Tabletop -type d -iname parent | xargs) -type f -print0 | xargs > Parent_Files_TT.csv

And have also tried "*":

find $(find /Volumes/COMMON-LIC-PHOTO/STUDIO-COMPLETE/ARCHIVE/Tabletop -type d -iname parent | xargs) -type f -name "*" > Parent_Files_TT.csv

But I'm getting the same error. If someone can help me modify this I'd be really grateful.

Upvotes: 0

Views: 714

Answers (2)

that other guy
that other guy

Reputation: 123490

Rather than putting a find in your find, just do it in one pass:

find /Volumes/COMMON-LIC-PHOTO/STUDIO-COMPLETE/ARCHIVE/Tabletop \
    -ipath '*/parent/*' -type f

Upvotes: 1

Benjamin W.
Benjamin W.

Reputation: 52162

This part

find /Volumes/COMMON-LIC-PHOTO/STUDIO-COMPLETE/ARCHIVE/Tabletop \
    -type d -iname parent

returns too many results, and your outer command becomes too long. You can avoid that by nesting your finds differently:

find /Volumes/COMMON-LIC-PHOTO/STUDIO-COMPLETE/ARCHIVE/Tabletop \
    -type d -iname parent \
    -exec find {} -type f \; > Parent_Files_TT.csv

Upvotes: 2

Related Questions