LS and spaces in path names (the xth)

Andreas Eibach ae_cygwin1@web.de
Tue Jun 28 13:36:00 GMT 2005


Yes, this is the umpteenth time this gets asked, but also the umpteenth plead to fix this in cygwin (as it _definitely_ works in Linux, also with vfat and non-Linux partitions!!)

I have two files in ~, say they're 

CD0.dat
CD1 - Multimedia (foo1).dat
CD2 - Multimedia2 (foo2).dat

+++++++++++++++++++++++++++++++++++++++++
Precondition: Imagine that the 'TAB' key doesn't function.
+++++++++++++++++++++++++++++++++++++++++
(since if I want to write a script, it should be _portable_; and if 
 it can be only be made work _with_ TAB, it is a kludge and 
 should be fixed properly. Period.)

ls -hog CD*   
[NB: ls -hog is smarter, because shorter in output;
 for this "exercise" we'll need neither group nor owner]

works and shows the three files:

-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

So far, so good.

But all attempts show files with -CD- -SPACE- -NUMBER 1 or 2- failed:

ls -hog "CD *"
ls: CD *: No such file or directory

also

ls -hog "CD [12]*"
ls: CD [12]*: No such file or directory

fails.

But

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!
At least it does not seem to be a "real" space, since I've tried
using option -b in LS and got nothing but also this '\ ' crap.
But as soon as the next file entry began, I got a correct '\n'.
I have tried to replace the character between CD and the [12] by various characters (tab and so on), but could never get a match.
I've also tried ' ' ticks, but without success.

Needless to say that scripts containing

for i in `ls *.dat*`; do .... 

will NOT work, because Cygwin will interpret each sub-string between the \ ' s separately, making parsing files a nuisance.
I scanned the archives and found something about using xargs. I've never used this command (except for finding strings); but if Cygwin is called a "win32 unix layer" shouldn't it behave like Unix and at least WORK with the above line?

You can't deny at least one of these shown DO work in Unix and Linux.
Without kludges, that is. So I'd say this is an issue and should at least be tackled.

-Andreas

_________________________________________________________________________
Mit der Gruppen-SMS von WEB.DE FreeMail können Sie eine SMS an alle 
Freunde gleichzeitig schicken: http://freemail.web.de/features/?mc=021179




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



More information about the Cygwin mailing list