[adam@rosi-kessel.org: Re: [Linux-disciples] xargs questions]
Adam Rosi-Kessel
adam at rosi-kessel.org
Thu Nov 11 09:10:44 EST 2004
This didn't appear to go through--trying again?
----- Forwarded message from Adam Rosi-Kessel <adam at rosi-kessel.org> -----
Date: Thu, 11 Nov 2004 08:18:29 -0500
From: Adam Rosi-Kessel <adam at rosi-kessel.org>
To: Community of interest for free software support <linux-disciples at lists.bostoncoop.net>
Subject: Re: [Linux-disciples] xargs questions
On Wed, Nov 10, 2004 at 09:32:13PM -0500, Stephen R Laniel wrote:
> asv '^gnome' |ig upgradeable |sed 's/^\(.*\)\/.*$/\1/' |xargs -i sagit '{}'
[...]
> If instead I take the output of sed and pipe it through
> "tr '\n' ' '" -- to convert all the newlines to spaces --
> xargs seems to send along a final newline that it shouldn't
> send, which ends up answering 'no' to a question that
> apt-get install asks me. This aborts the installation.
> So: how do I get all the lines output by sed to be processed
> through xargs the way I expect?
There are much easier ways to do this with aptitude. But let's assume
you don't want to use aptitude.
The easiest fix would just be to include -y in your apt-get options and
then you won't have tho 'no' problem.
Otherwise, I think the reason it's answering 'no' might not be the
newline at the end, but because STDIN has been redirected and it's not
getting control back from the keyboard--once you've started the pipe,
it's there for the whole process.
Note that the '{}' is necessarily linked to -i; you can specify an
arbitrary replacement script after -i, but the default is '{}'. Without
-i, there is no '{}'.
> I thought the point of xargs was to create commands that
> fit on the command line -- e.g., if there were too many
> upgradeable packages in my problem above, bash would tell
> me that my command line was too long and abort. xargs is
> then essentially a hack to get around a deficiency in bash,
> right? Or no? If that's its job, what is it doing in the
> 'tail -$LINES' command line above?
I'm not sure what it's doing in the tail command above, but the point of
xargs is *not* to create commands that fit on the command line--the point
is to take STDIN and convert it to arguments to a command. It's
essential glue.
--
Adam Rosi-Kessel
http://adam.rosi-kessel.org
----- End forwarded message -----
--
Adam Rosi-Kessel
http://adam.rosi-kessel.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.bostoncoop.net/pipermail/linux-disciples/attachments/20041111/31d2eceb/attachment.pgp
More information about the Linux-disciples
mailing list