delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
X-SWARE-Spam-Status: | No, hits=2.1 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_64,RCVD_IN_CHINA,RCVD_IN_DNSWL_LOW,RCVD_NUMERIC_HELO,SPF_HELO_PASS,SPF_PASS |
X-Spam-Check-By: | sourceware.org |
To: | cygwin AT cygwin DOT com |
From: | Hongyi Zhao <hongyi DOT zhao AT gmail DOT com> |
Subject: | Re: Delete a specific type of files when they exist. |
Date: | Fri, 09 Jan 2009 21:38:15 +0800 |
Lines: | 38 |
Message-ID: | <hjkem49kere1sftdo06po7adjapjqq4s48@4ax.com> |
References: | <rfidm4hfs5p9h6s40obf5s083onsau7j26 AT 4ax DOT com> <49674D3B DOT 20008 AT byu DOT net> |
Mime-Version: | 1.0 |
X-IsSubscribed: | yes |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.com> |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sourceware.org/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
On Fri, 09 Jan 2009 06:12:27 -0700, Eric Blake <ebb9 AT byu DOT net> wrote: >-----BEGIN PGP SIGNED MESSAGE----- >Hash: SHA1 > >According to Hongyi Zhao on 1/8/2009 8:55 PM: >> if [ -f *.cache-2 ] rm *.cache-2 >> >> But it seems that this -f parameter in the _if_ command will not work >> with wildcard, i.e., the _[ -f *.cache-2 ]_ isn't a valid arg. Any >> hints on this issue? > >Not cygwin specific. Your problem is that using a glob can expand to more >than one argument, whereas "[ -f ... ]" expects exactly one argument in >place of ...; Thanks for your analyse. > using echo will show you where you went wrong: > >echo [ -f *.cache-2 ] But I cann't figure this out, see the following results on my box: $ echo [ -f *.cache-2 ] [ -f *.cache-2 ] I cann't see any differences between your code and the following one: $ echo something and something something and something Could you please give me some more hints? Regards, -- .: Hongyi Zhao [ hongyi.zhao AT gmail.com ] Free as in Freedom :. -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |