From owner-freebsd-questions@FreeBSD.ORG Sat Nov 22 09:43:14 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B98CB16A4CE for ; Sat, 22 Nov 2003 09:43:14 -0800 (PST) Received: from heron.mail.pas.earthlink.net (heron.mail.pas.earthlink.net [207.217.120.189]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3D2E743FA3 for ; Sat, 22 Nov 2003 09:43:13 -0800 (PST) (envelope-from richardcoleman@mindspring.com) Received: from titan.criticalmagic.com ([68.213.16.23] helo=mindspring.com) by heron.mail.pas.earthlink.net with asmtp (Exim 3.33 #1) id 1ANbmq-00002O-00; Sat, 22 Nov 2003 09:43:12 -0800 Message-ID: <3FBFA039.4010109@mindspring.com> Date: Sat, 22 Nov 2003 12:43:21 -0500 From: Richard Coleman Organization: Critical Magic, Inc. User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20031007 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Zhang Weiwu References: <3FBF5E71.8050809@hotmail.com> In-Reply-To: <3FBF5E71.8050809@hotmail.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-ELNK-Trace: 1ee258965991efcb0865379cdb43356e5e89bb4777695beb702e37df12b9c9ef8c7e86447d4df7efbfd48ad3526fa4ff350badd9bab72f9c350badd9bab72f9c cc: freebsd-questions@freebsd.org Subject: Re: newbie: to pipe the result of a program as commandlineparameter for another. X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: richardcoleman@mindspring.com List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 Nov 2003 17:43:14 -0000 Zhang Weiwu wrote: > Hello. I just checkouted a big program. What I want to do is to remove > all CVS/ folders from the hierarchy. > > There might be other ways to do so (give me a hint?). What I can think > of is to run find(1) to find out all CVS folders, and pass them as > parameters of rm(1), but I don't know how to do so. That's the purpose of the "xargs" command. For instance, if you wanted to recursively delete all files in the directory /home/foo ending in ".o", you could use the command find /home/foo -name '*.o' -print | xargs rm -f Of course, people will point out that find has options that will allow it to remove files directly. But using xargs is a more general technique that will work in other situations. For instance, if you wanted to "touch" all your *.c files so that they have current modification times, you could use the following find /home/foo -name '*.c' -print | xargs touch Also, xargs knows about the maximum size allowable for the command line, and will use the minimum number of process invocations necessary. Richard Coleman richardcoleman@mindspring.com