bedtime question : xargs

Bill Campbell linux-sxs at celestial.com
Thu Apr 23 09:36:23 PDT 2009


On Thu, Apr 23, 2009, David A. Bandel wrote:
>On Wed, Apr 22, 2009 at 10:59 PM, Vu Pham <vu at sivell.com> wrote:
>> Using xargs, how can I pipe the output ( of some command ) as the *first*
>> parameter of some other command ?
>>
>> Here is my problem: I have various rpm files in a directory tree. I want to
>> copy all of these files to a remote server using scp. What I am thinking is
>>
>> [oliver at xen2vm4 redhat]$ find . -name "*.rpm"
>> ./SRPMS/hello-1.0.0-2.src.rpm
>> ./SRPMS/hello-1.0.0-1.src.rpm
>> ./RPMS/i686/hello-1.0.0-2.i686.rpm
>> ./RPMS/i686/hello-1.0.0-1.i686.rpm
>>
>>
>> # find . -name "*.rpm" | xargs  scp  ???   root at remoteserver:
>
>why invoke xargs at all?
>find . -name \*.rpm -exec scp {} root at remoteserver: \;
>(note:  the \; is required)

Better yet, why not use rsync?  It is more efficient than scp
when files may exist on the remote machine, uses ssh when not
using its own modules (e.g. host::module), and using modules can
be done reasonably safely without ssh by restricting the IP
addresses of hosts allowed to send data.

Bill
-- 
INTERNET:   bill at celestial.com  Bill Campbell; Celestial Software LLC
URL: http://www.celestial.com/  PO Box 820; 6641 E. Mercer Way
Voice:          (206) 236-1676  Mercer Island, WA 98040-0820
Fax:            (206) 232-9186  Skype: jwccsllc (206) 855-5792

The very powerful and the very stupid have one thing in common.
Instead of altering their views to fit the facts, they alter the facts
to fit their views ... which can be very uncomfortable if you happen to
be one of the facts that needs altering.  -- Doctor Who, "Face of Evil"



More information about the Linux-users mailing list