{ "name": "xargs", "section": 1, "title": "construct argument lists and invoke utility", "synopsis": [ "xargs [OPTION]... [OPERAND]..." ], "description": "Reads stdin into argument batches and runs **`ctx.runBinCommand`** (same as the shell). Enforces stdin size, token count, batch size, and invocation limits for safety. Parallel **`-P`** runs disjoint batches concurrently using shallow ctx clones so **`exitCode`** does not race.", "options": [ { "flag": "-0, --null", "meaning": "Input items are null-terminated, not whitespace-separated" }, { "flag": "-n, --max-args", "meaning": "Up to N arguments per utility invocation (capped at 128)" }, { "flag": "-I repl", "meaning": "Replace repl in the utility argv; implies **`-n 1`** unless **`-n`** was set" }, { "flag": "-P, --max-procs", "meaning": "Run up to N batches in parallel (capped by **`BARE_OS_XARGS_MAX_PROCS`**, max 32; default 8)" } ], "keywords": [ "xargs", "bare-os", "coreutils" ], "bareOsNotes": "No host process spawn; not full POSIX xargs. See **`src/xargs.js`** for limits. POSIX coverage: **`/etc/bare-os/posix_utilities.json`** (utilities.xargs).", "examples": [ { "caption": "pass lines as arguments", "code": "printf 'a\\nb\\n' | xargs echo" }, { "caption": "one argument per run", "code": "printf 'a\\nb\\n' | xargs -n1 echo" }, { "caption": "two parallel batches (when safe for the utility)", "code": "printf 'a\\nb\\n' | xargs -P2 -n1 echo" }, { "caption": "workaround for complex scripts", "code": "# for f in *.txt; do grep -l foo $f; done" } ] }