# Using Xargs to Get Past Argument List Too Long

DevFeed: [Using Xargs to Get Past Argument List Too Long](<https://devfeed.tech/articles/using-xargs-to-get-past-argument-list-too-long-28190.md>)

Original publisher: [Read original article](<http://fuzzyblog.io/blog/linux/2019/12/12/using-xargs-to-get-past-argument-list-too-long.html>)

Author: Fuzzygroup

Published: 2019-12-12T00:00:00Z

Content type: tutorial

Language: en

Sources: [Scott Johnson](<https://devfeed.tech/sources/scott-johnson.md>)

Topics: [JSON](<https://devfeed.tech/topics/json.md>), [Zsh](<https://devfeed.tech/topics/zsh.md>), [data](<https://devfeed.tech/topics/data.md>)

Tags: [json](<https://devfeed.tech/tags/json.md>), [linux](<https://devfeed.tech/tags/linux.md>), [zsh](<https://devfeed.tech/tags/zsh.md>)

## AI overview

A short tutorial explains how to use find and xargs to search approximately 25,000 JSON files without triggering the shell's "argument list too long" error. It also shows how to list only matching filenames with xargs and grep's -l option.

## Source excerpt

This one is a quick one. I have about 25,000 files in a directory that I need to grep across. I tried: grep '"class":0' *.json | more zsh: argument list too long: grep That's a problem because when the argument list is too long, nothing can happen. The solution here is a combination of find and xargs, specifically: find . -name '*.json' | xargs grep '"class":0' Here's the output from this: ./davidson-data-266118b4178f11ea80474c3275928de7.json:{"count":3,"hate_speech":3,"offensive_speech":0,"neither":0,"class":0,"tweet":"\"@JPantsdotcom @Todd__Kincannon @the__realtony I'm partial You should be able to use an approach like this: find -name '*.json' -exec grep '"class":0' but the embedded grep in find doesn't accept that and fails with this error: find: illegal option -- n usage: find [-H | -L | -P] [-EXdsx] [-f path] path ... [expression] find [-H | -L | -P] [-EXdsx] -f path [path ...] [expression] The closest that I can get to make this work is: find . -name '*.json' -exec grep 'class' {} + and that's not an exact match so, sigh. If we return to the original approach and add a -l option flag then we can list only filenames: find . -name '*.json' | xargs grep -l '"class":0' See Also Stack Overflow on Xargs Stack Overflow on Grep Argument List Too Long