From owner-freebsd-questions@FreeBSD.ORG Sat Nov 22 07:52:44 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 5E65516A4CE for ; Sat, 22 Nov 2003 07:52:44 -0800 (PST) Received: from ms-smtp-01-eri0.southeast.rr.com (ms-smtp-01-lbl.southeast.rr.com [24.25.9.100]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4C45D43F3F for ; Sat, 22 Nov 2003 07:52:41 -0800 (PST) (envelope-from wegster@mindcore.net) Received: from mindcore.net (rdu163-100-105.nc.rr.com [24.163.100.105]) hAMFqdse023261; Sat, 22 Nov 2003 10:52:40 -0500 (EST) Message-ID: <3FBF8646.7030905@mindcore.net> Date: Sat, 22 Nov 2003 10:52:38 -0500 From: Scott W 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: Herculano de Lima Einloft Neto References: <3FBF67F5.1020704@ig.com.br> In-Reply-To: <3FBF67F5.1020704@ig.com.br> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 Nov 2003 15:52:44 -0000 Herculano de Lima Einloft Neto wrote: > You can use: > > find [whatever] -exec rm -rf '{}' \; > > or > > find [whatever] | xargs rm -rf > > Usually, the answer to your question would be: use xargs or put the > second command between apostrophes. Something like: > > vi `which mozilla` > > I think if you use rm -rf `find [whatever]` it might work.. > > DON'T use these lines unless you're absolutely sure your find will > return exactly what you want.. rm -rf is the most destructive Unix > command, so if you don't know what you're doing, maybe you should wait > a couple of months until you do. :) Amen ;-) Seriously, the best thing you can do is just run the 'file listing' or 'data portion' of any command you're going to pipe together (or use -exec, xargs, redirection) by ITSELF, to make sure you're getting the expected results, sanity check the results, and THEN using command history, bring up the same command and wrap it in backticks or add the -exec or | xargs clause to it. Consider the following, and what would happen if BOTH were executed blindly: find /tmp -name "jre*" -exec rm {} \; OK, life's happy, remove all jre* files in the /tmp heirarchy. find / tmp -iname "jre.*" -exec rm {} \; Oops, accidently put a space between / and tmp. Hope you didn't actually WANT a working Java/jre on your system! Sane way: find /tmp -name "jre*" check results If OK, then use the SAME EXACT COMMAND via shell command line editing, and just wrap or add to it: find /tmp -name "jre*" -exec rm -f {} \; Scott > Read the man pages for rm, find and xargs so you can understand this. > > Best, > -- > Herculano de Lima Einloft Neto > > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to > "freebsd-questions-unsubscribe@freebsd.org" >