4 ms·
I'd give half marks for this, because it optimizes (meaninglessly) for processes, at the risk of ending up with "rm: Too many arguments" in a directory tree con
by aaronem 13y ago
I'd give half marks for this, because it optimizes (meaninglessly) for processes, at the risk of ending up with "rm: Too many arguments" in a directory tree containing a sufficiently large number of MP3 files.
- falsedan 13y agozero marks for not understanding how xargs works
- tene 13y agoxargs knows the maximum command line length, and will invoke the program more than once if necessary. One of the points of xargs is to break up invocations of a program into chunks of arguments that fit in one maximum length command line. xargs reads items from the standard input, delimited by blanks (which can be protected with double or single quotes or a backslash) or newlines, and executes the command (default is /bin/echo) one or more times with any initial- arguments followed by items read from standard input. --max-chars=max-chars -s max-chars Use at most max-chars characters per command line, including the command and initial-arguments and the terminating nulls at the ends of the argument strings. The largest allowed value is sys‐ tem-dependent, and is calculated as the argument length limit for exec, less the size of your environment, less 2048 bytes of headroom. If this value is more than 128KiB, 128Kib is used as the default value; otherwise, the default value is the maximum. 1KiB is 1024 bytes.
- falsedan 13y agoWell put
- aaronem 13y agoWell, how about that! It could be that I formed my opinion regarding xargs before it got that smart, or it could be the old Red Hat boxes on which I mostly learned my craft didn't bother compiling in that capability. Either way, I'm glad to know about it now, and thank you very kindly for pointing it out to me!
- tene 13y agoxargs knows the maximum command line length, and will invoke the program more than once if necessary. One of the points of xargs is to break up invocations of a program into chunks of arguments that fit in one maximum length command line. xargs reads items from the standard input, delimited by blanks (which can be protected with double or single quotes or a backslash) or newlines, and executes the command (default is /bin/echo) one or more times with any initial- arguments followed by items read from standard input. --max-chars=max-chars -s max-chars Use at most max-chars characters per command line, including the command and initial-arguments and the terminating nulls at the ends of the argument strings. The largest allowed value is sys‐ tem-dependent, and is calculated as the argument length limit for exec, less the size of your environment, less 2048 bytes of headroom. If this value is more than 128KiB, 128Kib is used as the default value; otherwise, the default value is the maximum. 1KiB is 1024 bytes.