Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 12 Aug 1998 17:46:39 +0200 (CEST)
From:      Malte Lance <malte.lance@gmx.net>
To:        Roman Katsnelson <romank@graphnet.com>
Cc:        "q's" <freebsd-questions@FreeBSD.ORG>
Subject:   Re: removing files
Message-ID:  <13777.47045.480782.154919@neuron.webmore.de>
In-Reply-To: <35D195D9.CD9E1460@graphnet.com>
References:  <35D195D9.CD9E1460@graphnet.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Roman Katsnelson writes:
 > Hi,
 > 
 > Let's say I have a directory with la.txt and foo.sh and 6 million other
 > files.

Let's say that directory is named "/tmp"

 > 
 > Can I issue a command that says: delete everything BUT la.txt and
 > foo.sh

yes.

 > 
 > 
 > According to man rm there's no way to do it with that one. Is there an
 > alternative?

Yes. "man grep" is your friend.

Try (in [ba]sh-world) :
  rm -f `/bin/ls /tmp/. | grep -v -e la.txt | grep -v -e foo.sh`

The tickmarks are back-ticks !

Malte.

 > 
 > Thanks,
 > 
 > Roman
 > -- 
 > Roman Katsnelson                
 > UNIX Network Engineer 
 > Graphnet, Inc.
 > 
 > To Unsubscribe: send mail to majordomo@FreeBSD.org
 > with "unsubscribe freebsd-questions" in the body of the message

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?13777.47045.480782.154919>