From owner-freebsd-questions Sat Aug 26 1:56:55 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 1F6B237B43C for ; Sat, 26 Aug 2000 01:56:49 -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 NAA08945 for ; Sat, 26 Aug 2000 13:12:18 +0400 (MSD) (envelope-from igor@raduga.dyndns.org) Received: (from igor@localhost) by raduga.dyndns.org (8.10.0/8.10.0) id e7Q8uDw27553 for freebsd-questions@FreeBSD.ORG; Sat, 26 Aug 2000 12:56:13 +0400 Date: Sat, 26 Aug 2000 12:56:13 +0400 From: Igor Roboul To: freebsd-questions@FreeBSD.ORG Subject: Re: how to delete all files but the XYZ file. Message-ID: <20000826125613.B27330@linux.rainbow> Reply-To: igorr@crosswinds.net Mail-Followup-To: freebsd-questions@FreeBSD.ORG References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0pre4i In-Reply-To: ; from yurtesen@ispro.net.tr on Sat, Aug 26, 2000 at 11:25:00AM +0300 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 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 ----------------------- Pay attention, that mv does not move CONTENT of file, so this may be very fast -- 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