Midhun
Midhun

Reputation: 11

Argument list too long error for Find command

I wanted to find the file name with posted time from sub directories, The below code was working fine but all of a sudden I'm getting Argument list too long error.

find /bishare/IRP_PROJECT/SXM_SFTP/*/INBOUND/* -name "*.xml" -type f -print0 | xargs -0 stat -c "%y  %n"   >> /appinfprd/bi/infogix/IA83/InfogixClient/Scripts/IRP/File_Posted_$CURRENT_DATE.txt

Upvotes: 0

Views: 639

Answers (2)

Midhun
Midhun

Reputation: 11

find /bishare/IRP_PROJECT/SXM_SFTP/ -path '*/INBOUND/*.xml' -exec stat -c "%y %n" {} \; >>/appinfprd/bi/infogix/IA83/InfogixClient/Scripts/IRP/File_Posted_$CURRENT_DATE.txt

Upvotes: 0

tripleee
tripleee

Reputation: 189487

The error happens if the expansion of the wildcard produces more characters than will fit into ARG_MAX.

Try to split it up so there is no wildcard.

find /bishare/IRP_PROJECT/SXM_SFTP/ -type -d -name INBOUND -execdir \
    find . -name "*.xml" -type f -print0 \; |
xargs -0 stat -c "%y  %n"  >> /appinfprd/bi/infogix/IA83/InfogixClient/Scripts/IRP/File_Posted_$CURRENT_DATE.txt

Upvotes: 2

Related Questions