delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/06/28/09:39:12

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
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
Message-ID: <42C1528B.6040001@byu.net>
Date: Tue, 28 Jun 2005 07:37:15 -0600
From: Eric Blake <ebb9 AT byu DOT net>
User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)
MIME-Version: 1.0
To: Andreas Eibach <ae_cygwin1 AT web DOT de>
CC: cygwin AT cygwin DOT com
Subject: Re: LS and spaces in path names (the xth)
References: <1478765723 AT web DOT de>
In-Reply-To: <1478765723@web.de>
X-IsSubscribed: yes

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Andreas Eibach on 6/28/2005 7:14 AM:
> 
> -rw-r--r-- 1       0  Jun 28  14:46  CD0.dat
> -rw-r--r-- 1   24K  Jun 28  14:46  CD 1 - Multimedia.dat
> -rw-r--r-- 1  2.9K  Jun 28  14:46  CD 2 - Multimedia.dat
...
> ls -hog "CD*[12]*"
> 
> WORKS.
> But why?
> After the 'CD', what character is this in Cygwin?
> It seems, it's not a valid character at all!

HINT - ls -Q shows a quoted representation of filenames, including those
mystery characters that aren't spaces.  But since Windows doesn't allow
tabs in filenames, and I doubt you are using a managed mount, it might
very well be a space.  Another thing to remember is that * filename
expansion only works if the * is not quoted, so try:
ls -hog "CD "*[12]*
rather than
ls -hog "CD *[12]*"

> Needless to say that scripts containing
> 
> for i in `ls *.dat*`; do .... 
> 
> will NOT work, 

Because you are typing too much (and by the way, this issue of scripting
vs. filenames with whitespace is not unique to cygwin).  The shorter
version below does what you want (since filename expansion occurs after
word splitting), and is faster to boot (one less process)!

for i in *.dat*; do
  echo "$i"

- --
Life is short - so eat dessert first!

Eric Blake             ebb9 AT byu DOT net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCwVKL84KuGfSFAYARAkvEAJ0QyChd9KoF7sEGf2QaPMcKZTfCYQCg1F3d
g78arm8H5en6pGoZpJjuswk=
=cM2d
-----END PGP SIGNATURE-----

--
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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019