From owner-freebsd-questions@FreeBSD.ORG Mon Nov 8 20:49:16 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 60B89106564A for ; Mon, 8 Nov 2010 20:49:16 +0000 (UTC) (envelope-from frank@esperance-linux.co.uk) Received: from asmtp2.iomartmail.com (asmtp2.iomartmail.com [62.128.201.249]) by mx1.freebsd.org (Postfix) with ESMTP id E620B8FC1D for ; Mon, 8 Nov 2010 20:49:15 +0000 (UTC) Received: from asmtp2.iomartmail.com (localhost.localdomain [127.0.0.1]) by asmtp2.iomartmail.com (8.13.8/8.13.8) with ESMTP id oA8KnD7U009210; Mon, 8 Nov 2010 20:49:13 GMT Received: from orange.esperance-linux.co.uk (80-45-152-196.static.dsl.as9105.com [80.45.152.196]) (authenticated bits=0) by asmtp2.iomartmail.com (8.13.8/8.13.8) with ESMTP id oA8KnDec009204; Mon, 8 Nov 2010 20:49:13 GMT Received: by orange.esperance-linux.co.uk (Postfix, from userid 1001) id A112733C1F; Mon, 8 Nov 2010 20:49:12 +0000 (GMT) Date: Mon, 8 Nov 2010 20:49:12 +0000 From: Frank Shute To: Jerry McAllister Message-ID: <20101108204912.GB3662@orange.esperance-linux.co.uk> References: <20101108154818.GD97242@gizmo.acns.msu.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20101108154818.GD97242@gizmo.acns.msu.edu> User-Agent: Mutt/1.4.2.3i X-Face: *}~{PHnDTzvXPe'wl_-f%!@+r5; VLhb':*DsX%wEOPg\fDrXWQJf|2\,92"DdS%63t*BHDyQ|OWo@Gfjcd72eaN!4%NE{0]p)ihQ1MyFNtWL X-Operating-System: FreeBSD 8.1-RELEASE-p1 amd64 X-Organisation: 'shute.org.uk' Cc: freebsd-questions@freebsd.org, yoganjaneyulu kasetti Subject: Re: removing files X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Frank Shute List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Nov 2010 20:49:16 -0000 On Mon, Nov 08, 2010 at 10:48:18AM -0500, Jerry McAllister wrote: > > On Mon, Nov 08, 2010 at 11:40:20AM +0530, yoganjaneyulu kasetti wrote: > > > hi, > > > > I have a problem for deleting files using script........please some one can > > guide me for the same. > > > > I have some files with the extension of ".chk" extension along with the > > extension of ".log" and ".gjf" extension in the folder called different *input > > folders. *I wanted to delete the ".chk" file extension having files. If i go > > to individual input folder manually i can delete the file with *rm* command > > line by but i would like to delete all the ".chk" files extension files at a > > time through scripting rather than manual. So please some one help me for > > the same. > > /student/sweety/gaussiandata/*1249624064640*/input > > > > /student/sweety/gaussiandata/*1261202703914*/input > > > > /student/sweety/gaussiandata/*1263357080155*/input > > > > /student/sweety/gaussiandata/*1289106407303*/input > > Your examples given here don't seem to match quite what you are asking > as far as I see. Maybe I am looking at it wrong. > > But, anyway, can't you just the -R switch on the rm? > > cd top_of_tree_with_files_to_delete > rm -R *.chk > rm -R *.log > rm -R *.gjk > > Or am I missing something. > > ////jerry It could be that the OP has more files than the glob can handle. (With most shells there's a restriction....or used to be). I'm also reluctant to use a glob with rm without the -i. With find(1) you can do a dry run first before giving it the -delete argument. The OP also wants to use -maxdepth 1 with find(1) if he doesn't want to traverse the tree below his target dir. Regards, -- Frank Contact info: http://www.shute.org.uk/misc/contact.html