Sujet : xargs -x (was: IFS=$'\n')
De : geoff (at) *nospam* clare.See-My-Signature.invalid (Geoff Clare)
Groupes : comp.unix.shellDate : 15. Aug 2024, 14:53:04
Autres entêtes
Message-ID : <gaa1pk-lia.ln1@ID-313840.user.individual.net>
References : 1 2 3 4
User-Agent : Pan/0.154 (Izium; 517acf4)
Christian Weisgerber wrote:
On 2024-08-13, Ralf Damaschke <rwspam@gmx.de> wrote:
find . -iname \*fred\* -type f -exec ls -lt -- {} +
If sufficiently many files accrue, find(1) will invoke ls(1) several
times, which will not produce the expected result. That may be
unlikely in this specific example, but it can happen in the general
case.
Wait, you say, xargs(1) will also split its input across multiple
invocations. I mean, that's very much the point of xargs. Which
is why Helmut added the -x flag, which is supposed to prevent this
behavior.
It isn't supposed to do that, and it doesn't.
$ echo 1234567890 1234567890 | xargs -s 50 echo
1234567890 1234567890
$ echo 1234567890 1234567890 | xargs -s 20 echo
1234567890
1234567890
$ echo 1234567890 1234567890 | xargs -x -s 20 echo
1234567890
1234567890
Tested with GNU, macOS (with -n 10 added), and Solaris versions of xargs.
-- Geoff Clare <netnews@gclare.org.uk>