Re: Can't redirect output to file
- From: Nix <nix-razor-pit@xxxxxxxxxxxxx>
- Date: Sun, 13 Feb 2011 13:09:58 +0000
On 28 Jan 2011, unruh@xxxxxxxxxxxxxxxxxxxxxxx told this:
On 2011-01-28, Dean <de@xxxxxxxxxxxx> wrote:
I hadn't realised that xargs invokes the command specified once for each and
every item on stdin. My misunderstanding was that it passed its standard
Nope. It does neither. xargs reads in the complete stdin to a large,
expandable buffer. It then divides it up into a set of lists smaller
than the bash buffer size and feeds each list to the command.
Thus if say you had 50 items in the list, it would feed all 50 to the
command. If you have 50,000 it would divide it up into sublists each say
500 items long and feed each of those to the command. (It is not 500, it
is rather a fixed number of characters as the limit to the length of the
list).
Technically this is wrong.
xargs reads in as much of stdin as is necessary to fill up the argument
list of the command to be invoked, splits on words at the appropriate
point, executes the command with that list, then sucks some more
arguments in. It does not sponge in the entire argument list first.
This is important not just on small hardware but if the argument list is
being produced by some expensive process: xargs can get started faster
if it stops sucking and starts executing. (A downside is that if the
command *xargs is invoking* is slow, the command providing the filenames
might fill up its pipeline and block.)
.
- Prev by Date: Re: AGP graphics cards
- Next by Date: Re: AGP graphics cards
- Previous by thread: X equivalent of GNU screen
- Next by thread: Suse 11.3 kde4 monitor resolution
- Index(es):
Relevant Pages
|