From owner-freebsd-questions Sat Aug 26 3:54:50 2000 Delivered-To: freebsd-questions@freebsd.org Received: from srcso.globis.ru (globis.ru [212.248.80.7]) by hub.freebsd.org (Postfix) with ESMTP id F02B437B423 for ; Sat, 26 Aug 2000 03:54:41 -0700 (PDT) Received: from raduga.dyndns.org (raduga.sochi.net [212.248.82.76]) by srcso.globis.ru (8.9.3/8.9.3) with ESMTP id PAA09139 for ; Sat, 26 Aug 2000 15:10:23 +0400 (MSD) (envelope-from igor@raduga.dyndns.org) Received: (from igor@localhost) by raduga.dyndns.org (8.10.0/8.10.0) id e7QAsVl28143 for freebsd-questions@FreeBSD.ORG; Sat, 26 Aug 2000 14:54:31 +0400 Date: Sat, 26 Aug 2000 14:54:31 +0400 From: Igor Roboul To: freebsd-questions@FreeBSD.ORG Subject: Re: how to delete all files but the XYZ file. Message-ID: <20000826145431.A28124@linux.rainbow> Reply-To: igorr@crosswinds.net Mail-Followup-To: freebsd-questions@FreeBSD.ORG References: <20000826125613.B27330@linux.rainbow> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0pre4i In-Reply-To: ; from andyf@speednet.com.au on Sat, Aug 26, 2000 at 08:18:52PM +1000 X-Operating-System: Linux linux.rainbow 2.2.14-plus-SMP X-Best-Window-Manager: Window Maker (www.windowmaker.org) Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Sat, Aug 26, 2000 at 08:18:52PM +1000, Andy Farkas wrote: > > On Sat, 26 Aug 2000, Igor Roboul wrote: > > > On Sat, Aug 26, 2000 at 11:25:00AM +0300, Evren Yurtesen wrote: > > > Lets say I have 1230 files in one directory and I want to delete > > > all of the files but not the files named XYZ, XYA, XYB etc. > > > I want to do this from shell without using any file managers. (since > > > actually I need to do this from a script) > > Is there any directories? If no, then how do you think about this? > > ----------------------- > > mkdir .preserve > > mv XY* .preserve > > rm -f * > > mv .preserve/* . > > rmdir .preserve > > ----------------------- > > Where did you learn about .preserve? Is it a shell thing or an rm thing? .preserve is just _directory_ if you like then you can name it PROTECT :-) It's why I asked does your directory contain any subdirs? If it contain subdirs then you'll need change script. -- Igor Roboul, Unix System Administrator & Programmer @ sanatorium "Raduga" http://www.brainbench.com/transcript.jsp?pid=304744 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message