This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: LS and spaces in path names (the xth)


-----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@byu.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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]