public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Re: How do I list subdirectories?
@ 1999-08-25  5:24 Earnie Boyd
  1999-08-31 23:49 ` Earnie Boyd
  0 siblings, 1 reply; 28+ messages in thread
From: Earnie Boyd @ 1999-08-25  5:24 UTC (permalink / raw)
  To: Clark Sims, cygwin

---  Clark Sims  <clarksimsgnu@my-Deja.com> wrote:
>  In the FSF version of bash
> ls -F | egrep *\/
> listed all of the subdirectories of the current working
> directory.
> In the Cygwin version the same command produces no
> output.
> 
> How do I list the subdirectories of the current working
> directory?
> 

Doesn't the egrep need to be `egrep .*\/'?  The period indicates any character,
the * indicates any number of the preceding character.  Therefore to match what
you want you need to specify .* to mean any number of any character.

===
Earnie Boyd < mailto:earnie_boyd@yahoo.com >

Newbies, please visit
< http://www.freeyellow.com/members5/gw32/index.html >

(If you respond to the list, then please don't cc me)
__________________________________________________
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: How do I list subdirectories?
  1999-08-25  5:24 How do I list subdirectories? Earnie Boyd
@ 1999-08-31 23:49 ` Earnie Boyd
  0 siblings, 0 replies; 28+ messages in thread
From: Earnie Boyd @ 1999-08-31 23:49 UTC (permalink / raw)
  To: Clark Sims, cygwin

---  Clark Sims  <clarksimsgnu@my-Deja.com> wrote:
>  In the FSF version of bash
> ls -F | egrep *\/
> listed all of the subdirectories of the current working
> directory.
> In the Cygwin version the same command produces no
> output.
> 
> How do I list the subdirectories of the current working
> directory?
> 

Doesn't the egrep need to be `egrep .*\/'?  The period indicates any character,
the * indicates any number of the preceding character.  Therefore to match what
you want you need to specify .* to mean any number of any character.

===
Earnie Boyd < mailto:earnie_boyd@yahoo.com >

Newbies, please visit
< http://www.freeyellow.com/members5/gw32/index.html >

(If you respond to the list, then please don't cc me)
__________________________________________________
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 28+ messages in thread

* RE: How do I list subdirectories?
  1999-08-25  8:06 John Wiersba
@ 1999-08-31 23:49 ` John Wiersba
  0 siblings, 0 replies; 28+ messages in thread
From: John Wiersba @ 1999-08-31 23:49 UTC (permalink / raw)
  To: ' Clark Sims ', cygwin

ls -F | grep /$
works.  I'm not sure why you used egrep or *\ in your version.  BTW, ls -F
won't catch directories which start with . (use -A) and it won't catch
symlinks to directories (use -L).

> -----Original Message-----
> From: Clark Sims [ mailto:clarksimsgnu@my-Deja.com ]
> Sent: Wednesday, August 25, 1999 8:13 AM
> To: cygwin@sourceware.cygnus.com
> Subject: How do I list subdirectories?
> 
> 
>  In the FSF version of bash
> ls -F | egrep *\/
> listed all of the subdirectories of the current working
> directory.
> In the Cygwin version the same command produces no
> output.
> 
> How do I list the subdirectories of the current working
> directory?
> 
> Thanks in Advance,
> 
> Clark Sims
> 
> 
> --== Sent via Deja.com http://www.deja.com/ ==--
> Share what you know. Learn what you don't.
> 
> --
> Want to unsubscribe from this list?
> Send a message to cygwin-unsubscribe@sourceware.cygnus.com
> 

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: How do I list subdirectories?
  1999-08-25  5:20 ` Kim Poulsen
@ 1999-08-31 23:49   ` Kim Poulsen
  0 siblings, 0 replies; 28+ messages in thread
From: Kim Poulsen @ 1999-08-31 23:49 UTC (permalink / raw)
  To: egcs; +Cc: cygwin

Clark Sims wrote:
>  In the FSF version of bash
> ls -F | egrep *\/
> listed all of the subdirectories of the current working
> directory.
> In the Cygwin version the same command produces no
> output.
> How do I list the subdirectories of the current working
> directory?

ls -lR
or if you only want the subdirs
ls -F |egrep \/

grep'ing for *\/ will search for files ending with '*/' 
which is hopefully none.

-- 
 Kim Poulsen, B.Sc.E.E, System Developer HW
 Ericsson Telebit A/S     Tel: + 45 86 28 81 76
 Fabriksvej 11            Fax: + 45 86 28 81 86
 DK-8260 Viby J           E-mail: info@tbit.dk
 Denmark                  URL: http://www.tbit.dk/

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: How do I list subdirectories?
  1999-08-25  6:10  Clark Sims 
                   ` (2 preceding siblings ...)
  1999-08-25 18:15 ` Ajit George
@ 1999-08-31 23:49 `  Clark Sims 
  3 siblings, 0 replies; 28+ messages in thread
From:  Clark Sims  @ 1999-08-31 23:49 UTC (permalink / raw)
  To: cygwin

 
--

On Wed, 25 Aug 1999 05:25:34   Earnie Boyd wrote:
>---  Clark Sims  <clarksimsgnu@my-Deja.com> wrote:
>>  In the FSF version of bash
>> ls -F | egrep *\/
>> listed all of the subdirectories of the current working
>> directory.
>> In the Cygwin version the same command produces no
>> output.
>> 
>> How do I list the subdirectories of the current working
>> directory?
>> 
>
>Doesn't the egrep need to be `egrep .*\/'?  The period indicates any character,
>the * indicates any number of the preceding character.  Therefore to match what
>you want you need to specify .* to mean any number of any character.
>

Nice try but 
ls -F | egrep .*\/ 
doesn't work.
I agree that it ought to. I don't understand why it
doesn't.

However Kim Poulsen found a command that does work:
ls -F | egrep \/

It seems that this is a question on pattern matching.
It seems to me that a directory which is mached by:
\/
should also be matched by
*\/
and 
.*\/

Maybe I will understand the difference in
interpretations as I become more familiar
with Cygwin. Untill then I am stumped.

Thanks,

Clark


--== Sent via Deja.com http://www.deja.com/ ==--
Share what you know. Learn what you don't.

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: How do I list subdirectories?
  1999-08-25  7:36 ` Keith Starsmeare
@ 1999-08-31 23:49   ` Keith Starsmeare
  0 siblings, 0 replies; 28+ messages in thread
From: Keith Starsmeare @ 1999-08-31 23:49 UTC (permalink / raw)
  To: Clark Sims; +Cc: cygwin

> >> How do I list the subdirectories of the current working
> >> directory?

I use:

ls -d `find * -type d -prune -print`

which I alias to lsd - trippy!

Keith

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 28+ messages in thread

* RE: How do I list subdirectories?
  1999-08-25 18:15 ` Ajit George
  1999-08-26 12:25   ` Josh Baudhuin
@ 1999-08-31 23:49   ` Ajit George
  1 sibling, 0 replies; 28+ messages in thread
From: Ajit George @ 1999-08-31 23:49 UTC (permalink / raw)
  To: cygwin

What's happening is that the shell is expanding *\/, which shouldn't match
any file name unless you've gone to the trouble of creating a file with '/'
in its name.

Ajit

-----Original Message-----
From:	cygwin-owner@sourceware.cygnus.com
[ mailto:cygwin-owner@sourceware.cygnus.com ] On Behalf Of  Clark Sims
Sent:	Wednesday, August 25, 1999 8:09 AM
To:	cygwin@sourceware.cygnus.com
Subject:	Re: How do I list subdirectories?


--

On Wed, 25 Aug 1999 05:25:34   Earnie Boyd wrote:
>---  Clark Sims  <clarksimsgnu@my-Deja.com> wrote:
>>  In the FSF version of bash
>> ls -F | egrep *\/
>> listed all of the subdirectories of the current working
>> directory.
>> In the Cygwin version the same command produces no
>> output.
>>
>> How do I list the subdirectories of the current working
>> directory?
>>
>
>Doesn't the egrep need to be `egrep .*\/'?  The period indicates any
character,
>the * indicates any number of the preceding character.  Therefore to match
what
>you want you need to specify .* to mean any number of any character.
>

Nice try but
ls -F | egrep .*\/
doesn't work.
I agree that it ought to. I don't understand why it
doesn't.

However Kim Poulsen found a command that does work:
ls -F | egrep \/

It seems that this is a question on pattern matching.
It seems to me that a directory which is mached by:
\/
should also be matched by
*\/
and
.*\/

Maybe I will understand the difference in
interpretations as I become more familiar
with Cygwin. Untill then I am stumped.

Thanks,

Clark


--== Sent via Deja.com http://www.deja.com/ ==--
Share what you know. Learn what you don't.

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com



--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 28+ messages in thread

* RE: How do I list subdirectories?
  1999-08-25 10:04 John Wiersba
  1999-08-25 12:07 ` Joshua Rosen
@ 1999-08-31 23:49 ` John Wiersba
  1 sibling, 0 replies; 28+ messages in thread
From: John Wiersba @ 1999-08-31 23:49 UTC (permalink / raw)
  To: 'Joshua Rosen', cygwin

<SNIP>

> I am wondering why using a backslash anyware in a shell expression
> escapes all of the asterisks, right now..., but that appears to be
> something about bash, not Cygwin.

It doesn't.  Go to any dir with subdirs and try

echo */
echo *\/
echo *\a*/   (assuming some subdir has an "a" in it)
echo *z*/    (assuming no subdir has a "z" in it)

If you have shopt -u nullglob (the default) then a failed pattern is left as
is.

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: How do I list subdirectories?
  1999-08-25  9:26 ` Joshua Rosen
@ 1999-08-31 23:49   ` Joshua Rosen
  0 siblings, 0 replies; 28+ messages in thread
From: Joshua Rosen @ 1999-08-31 23:49 UTC (permalink / raw)
  To: cygwin

Clark Sims wrote:
> 
> Nice try but
> ls -F | egrep .*\/
> doesn't work.
> I agree that it ought to. I don't understand why it
> doesn't.

Because the asterisk is neither quoted nor escaped, so it's being
expanded by the shell before it's fed to grep.

Use any of:
	'.*/'
	".*/"
	.\*/

Note that the forward slash doesn't need to be escaped--it's not a
special regexp character.

> However Kim Poulsen found a command that does work:
> ls -F | egrep \/

And this works (with less typing;)), because (e|f|)grep finds an
equivilant substring -anywhere- in the string that you grep from. You
only need the ".*" if you use it like "^.*" ;)

> 
> It seems that this is a question on pattern matching.
> It seems to me that a directory which is mached by:
> \/
> should also be matched by
> *\/
... if we're using shell patterns (which the grep command isn't).
In the regexps that grep is using, it'd be appropriate for you to be
told that your regexp is invalid, because there aren't any characters
before the Kleen star.
Remember, too, that the "*/" isn't being fed to grep, too--all of the
file-names, ending in '/', joined together by spaces, are, and that's
not going to match.

look at the string output by:
	echo */

I am wondering why using a backslash anyware in a shell expression
escapes all of the asterisks, right now..., but that appears to be
something about bash, not Cygwin.

Oh--a fairly good description of standard regexps (and all sorts of
other things) can be found in the Free Online Dictionary of Computing:
http://foldoc.doc.ic.ac.uk/

		-Rozzin.
-- 
-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GFA/CS/L/M/P/MU/O d(-) s:-- a? C++++$>$ UL P L+ E W+++ N-(!) o? K(--)
w(--)(---) O+++ M-- V? PS+++ PE Y+ PGP-(+++) t 5 X+ R* tv(+) b+ DI+
D---- G+++ e- h! r%--- y+
------END GEEK CODE BLOCK------
rozzin@geekspace.com -- http://i.am/rozzin

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: How do I list subdirectories?
  1999-08-25  6:44 Earnie Boyd
@ 1999-08-31 23:49 ` Earnie Boyd
  0 siblings, 0 replies; 28+ messages in thread
From: Earnie Boyd @ 1999-08-31 23:49 UTC (permalink / raw)
  To: cygwin users

---  Clark Sims  <clarksimsgnu@my-Deja.com> wrote:
-8<-
> It seems that this is a question on pattern matching.
> It seems to me that a directory which is mached by:
> \/
> should also be matched by
> *\/
> and 
> .*\/
> 
> Maybe I will understand the difference in
> interpretations as I become more familiar
> with Cygwin. Untill then I am stumped.
> 

My guess is that the * is begin interpretted as a globbing wildcard instead of
the regular expression wildcard and you're getting the list of files in the
current directory as the pattern to match.  You can test this by quoting the *.
===
Earnie Boyd < mailto:earnie_boyd@yahoo.com >

Newbies, please visit
< http://www.freeyellow.com/members5/gw32/index.html >

(If you respond to the list, then please don't cc me)
__________________________________________________
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 28+ messages in thread

* RE: How do I list subdirectories?
  1999-08-26 12:25   ` Josh Baudhuin
@ 1999-08-31 23:49     ` Josh Baudhuin
  0 siblings, 0 replies; 28+ messages in thread
From: Josh Baudhuin @ 1999-08-31 23:49 UTC (permalink / raw)
  To: cygwin

Well, he used ls -F, which will add the terminal /.

You could do something like
	find . -name './*' -type d -print


-----Original Message-----
From: Ajit George [ mailto:gajit@kurianinc.com ]
Sent: Wednesday, 25 August 1999 6:14 pm
To: cygwin@sourceware.cygnus.com
Subject: RE: How do I list subdirectories?


What's happening is that the shell is expanding *\/, which shouldn't match
any file name unless you've gone to the trouble of creating a file with '/'
in its name.

Ajit

-----Original Message-----
From:	cygwin-owner@sourceware.cygnus.com
[ mailto:cygwin-owner@sourceware.cygnus.com ] On Behalf Of  Clark Sims
Sent:	Wednesday, August 25, 1999 8:09 AM
To:	cygwin@sourceware.cygnus.com
Subject:	Re: How do I list subdirectories?


--

On Wed, 25 Aug 1999 05:25:34   Earnie Boyd wrote:
>---  Clark Sims  <clarksimsgnu@my-Deja.com> wrote:
>>  In the FSF version of bash
>> ls -F | egrep *\/
>> listed all of the subdirectories of the current working
>> directory.
>> In the Cygwin version the same command produces no
>> output.
>>
>> How do I list the subdirectories of the current working
>> directory?
>>
>
>Doesn't the egrep need to be `egrep .*\/'?  The period indicates any
character,
>the * indicates any number of the preceding character.  Therefore to match
what
>you want you need to specify .* to mean any number of any character.
>

Nice try but
ls -F | egrep .*\/
doesn't work.
I agree that it ought to. I don't understand why it
doesn't.

However Kim Poulsen found a command that does work:
ls -F | egrep \/

It seems that this is a question on pattern matching.
It seems to me that a directory which is mached by:
\/
should also be matched by
*\/
and
.*\/

Maybe I will understand the difference in
interpretations as I become more familiar
with Cygwin. Untill then I am stumped.

Thanks,

Clark


--== Sent via Deja.com http://www.deja.com/ ==--
Share what you know. Learn what you don't.

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com




--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: How do I list subdirectories?
  1999-08-25 12:07 ` Joshua Rosen
@ 1999-08-31 23:49   ` Joshua Rosen
  0 siblings, 0 replies; 28+ messages in thread
From: Joshua Rosen @ 1999-08-31 23:49 UTC (permalink / raw)
  To: egcs; +Cc: cygwin

John Wiersba wrote:
> 
> <SNIP>
> 
> > I am wondering why using a backslash anyware in a shell expression
> > escapes all of the asterisks, right now..., but that appears to be
> > something about bash, not Cygwin.
> 
> It doesn't.

Hrm. I think that my having not eaten was making me hallucinate--I'm
no longer seeing the files listed that I was when I used the same
wildcard characters....

-- 
-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GFA/CS/L/M/P/MU/O d(-) s:-- a? C++++$>$ UL P L+ E W+++ N-(!) o? K(--)
w(--)(---) O+++ M-- V? PS+++ PE Y+ PGP-(+++) t 5 X+ R* tv(+) b+ DI+
D---- G+++ e- h! r%--- y+
------END GEEK CODE BLOCK------
rozzin@geekspace.com -- http://i.am/rozzin

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: How do I list subdirectories?
  1999-08-25 13:41 13mb80000-HallM(DR3132)37x10
@ 1999-08-31 23:49 ` 13mb80000-HallM(DR3132)37x10
  0 siblings, 0 replies; 28+ messages in thread
From: 13mb80000-HallM(DR3132)37x10 @ 1999-08-31 23:49 UTC (permalink / raw)
  To: cygwin

> Nice try but 
> ls -F | egrep .*\/ 
> doesn't work.
> I agree that it ought to. I don't understand why it
> doesn't.


For a hint, try the command:
	echo .*\/
and you will see that the shell globs the argument.  Depending on the contents
of the directory, you will get something like ./ ../ as output from the echo.
So, the command:
	ls -F | egrep .*\/
is the same as saying
	ls -F | egrep ./ ../
Which certainly isn't what you want.

Try
	ls -F | egrep '.*\/'

> However Kim Poulsen found a command that does work:
> ls -F | egrep \/
> 
> It seems that this is a question on pattern matching.
> It seems to me that a directory which is mached by:
> \/
> should also be matched by
> *\/
> and 
> .*\/

Egrep works with regular expressions, shell works with glob expressions.
In regular expressions, the * means zero or more of whatever preceeded the
*.  Thus, in the second case, since there was nothing preceeding the *,
it really doesn't make sense as a regular expression.  If you pass that
to egrep (remember to quote it to protect it from the shell) egrep reports
a syntax error.

So, when passed to egrep, the first pattern recognizes a slash (I still
don't understand the need to escape the slash, since it has no particular
meaning to egrep.)  The second pattern is a syntax error, and the third
pattern matches anything (or nothing) and then a slash.

As shell glob expressions, the first pattern doesn't contain any glob
characters and so it would be passed as a slash (the shell does remove
the escape backslash).  The second pattern would match any path that can
be constructed with anything (the *) followed by a slash.  This gives
you all of the directories within the current directory (at least those
that don't start with a ., because the shell doesn't expand * to include
those files).  The third expression would match any path that can be
constructed with a leading ., then anything, then a slash.  So, using
the shell instead of egrep, we can come very close to the desired behavior
with the command:
	echo */ .*/
When the shell processes the arguments, the first argument will be replaced
with all directories that do not begin with a '.' and the second will be
replaced with all directories that do begin with a '.'.  The only problem
here is that if the pattern doesn't match anything, then it will be left
there and not expanded.  So, if you have a basically empty directory, this
will produce
	*/ ./ ../
since the first argument is not expanded (nothing matches it) and the second
matches the current and parent directories.  To eliminate this bother, we
can use ls instead and throw away the error, so the command:
	ls -d */ .*/ 2>/dev/null
should show all the directories within the current directory.

marcus hall

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: How do I list subdirectories?
  1999-08-25 14:23 13mb80000-HallM(DR3132)37x10
@ 1999-08-31 23:49 ` 13mb80000-HallM(DR3132)37x10
  0 siblings, 0 replies; 28+ messages in thread
From: 13mb80000-HallM(DR3132)37x10 @ 1999-08-31 23:49 UTC (permalink / raw)
  To: cygwin

A minor nit in an otherwise very clear and concise description of
the misunderstandings..

> > It seems that this is a question on pattern matching.
> > It seems to me that a directory which is mached by:
> > \/
> > should also be matched by
> > *\/
> ... if we're using shell patterns (which the grep command isn't).
> In the regexps that grep is using, it'd be appropriate for you to be
> told that your regexp is invalid, because there aren't any characters
> before the Kleen star.
> Remember, too, that the "*/" isn't being fed to grep, too--all of the
> file-names, ending in '/', joined together by spaces, are, and that's
> not going to match.

Actually, I believe that all of the file-names ending in '/' (that is,
all of the valid paths with an element of the current directory followed
by a slash, except for those beginning with a .) will be passed to egrep
as separate arguments.  egrep will interpret the first argument as the
pattern to search for, and the subsequent arguments as files to search for
the pattern in.  If there are two or more paths expanded, (i.e. egrep sees
a pattern and one or more files), egrep will not read standard input at
all and will instead search the "files" for the "pattern".

Depending on whether the OS allows a directory to be opened and read, egrep
may complain that it cannot open the "files", or it may open it and search
for the "pattern", which it probably would not find, but it just might if
the directory looked just right.

....

Well, I did say that it was a minor nit!

marcus hall

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 28+ messages in thread

* How do I list subdirectories?
  1999-08-25  5:13  Clark Sims 
  1999-08-25  5:20 ` Kim Poulsen
@ 1999-08-31 23:49 `  Clark Sims 
  1 sibling, 0 replies; 28+ messages in thread
From:  Clark Sims  @ 1999-08-31 23:49 UTC (permalink / raw)
  To: cygwin

 In the FSF version of bash
ls -F | egrep *\/
listed all of the subdirectories of the current working
directory.
In the Cygwin version the same command produces no
output.

How do I list the subdirectories of the current working
directory?

Thanks in Advance,

Clark Sims


--== Sent via Deja.com http://www.deja.com/ ==--
Share what you know. Learn what you don't.

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 28+ messages in thread

* RE: How do I list subdirectories?
  1999-08-25 18:15 ` Ajit George
@ 1999-08-26 12:25   ` Josh Baudhuin
  1999-08-31 23:49     ` Josh Baudhuin
  1999-08-31 23:49   ` Ajit George
  1 sibling, 1 reply; 28+ messages in thread
From: Josh Baudhuin @ 1999-08-26 12:25 UTC (permalink / raw)
  To: cygwin

Well, he used ls -F, which will add the terminal /.

You could do something like
	find . -name './*' -type d -print


-----Original Message-----
From: Ajit George [ mailto:gajit@kurianinc.com ]
Sent: Wednesday, 25 August 1999 6:14 pm
To: cygwin@sourceware.cygnus.com
Subject: RE: How do I list subdirectories?


What's happening is that the shell is expanding *\/, which shouldn't match
any file name unless you've gone to the trouble of creating a file with '/'
in its name.

Ajit

-----Original Message-----
From:	cygwin-owner@sourceware.cygnus.com
[ mailto:cygwin-owner@sourceware.cygnus.com ] On Behalf Of  Clark Sims
Sent:	Wednesday, August 25, 1999 8:09 AM
To:	cygwin@sourceware.cygnus.com
Subject:	Re: How do I list subdirectories?


--

On Wed, 25 Aug 1999 05:25:34   Earnie Boyd wrote:
>---  Clark Sims  <clarksimsgnu@my-Deja.com> wrote:
>>  In the FSF version of bash
>> ls -F | egrep *\/
>> listed all of the subdirectories of the current working
>> directory.
>> In the Cygwin version the same command produces no
>> output.
>>
>> How do I list the subdirectories of the current working
>> directory?
>>
>
>Doesn't the egrep need to be `egrep .*\/'?  The period indicates any
character,
>the * indicates any number of the preceding character.  Therefore to match
what
>you want you need to specify .* to mean any number of any character.
>

Nice try but
ls -F | egrep .*\/
doesn't work.
I agree that it ought to. I don't understand why it
doesn't.

However Kim Poulsen found a command that does work:
ls -F | egrep \/

It seems that this is a question on pattern matching.
It seems to me that a directory which is mached by:
\/
should also be matched by
*\/
and
.*\/

Maybe I will understand the difference in
interpretations as I become more familiar
with Cygwin. Untill then I am stumped.

Thanks,

Clark


--== Sent via Deja.com http://www.deja.com/ ==--
Share what you know. Learn what you don't.

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com




--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 28+ messages in thread

* RE: How do I list subdirectories?
  1999-08-25  6:10  Clark Sims 
  1999-08-25  7:36 ` Keith Starsmeare
  1999-08-25  9:26 ` Joshua Rosen
@ 1999-08-25 18:15 ` Ajit George
  1999-08-26 12:25   ` Josh Baudhuin
  1999-08-31 23:49   ` Ajit George
  1999-08-31 23:49 `  Clark Sims 
  3 siblings, 2 replies; 28+ messages in thread
From: Ajit George @ 1999-08-25 18:15 UTC (permalink / raw)
  To: cygwin

What's happening is that the shell is expanding *\/, which shouldn't match
any file name unless you've gone to the trouble of creating a file with '/'
in its name.

Ajit

-----Original Message-----
From:	cygwin-owner@sourceware.cygnus.com
[ mailto:cygwin-owner@sourceware.cygnus.com ] On Behalf Of  Clark Sims
Sent:	Wednesday, August 25, 1999 8:09 AM
To:	cygwin@sourceware.cygnus.com
Subject:	Re: How do I list subdirectories?


--

On Wed, 25 Aug 1999 05:25:34   Earnie Boyd wrote:
>---  Clark Sims  <clarksimsgnu@my-Deja.com> wrote:
>>  In the FSF version of bash
>> ls -F | egrep *\/
>> listed all of the subdirectories of the current working
>> directory.
>> In the Cygwin version the same command produces no
>> output.
>>
>> How do I list the subdirectories of the current working
>> directory?
>>
>
>Doesn't the egrep need to be `egrep .*\/'?  The period indicates any
character,
>the * indicates any number of the preceding character.  Therefore to match
what
>you want you need to specify .* to mean any number of any character.
>

Nice try but
ls -F | egrep .*\/
doesn't work.
I agree that it ought to. I don't understand why it
doesn't.

However Kim Poulsen found a command that does work:
ls -F | egrep \/

It seems that this is a question on pattern matching.
It seems to me that a directory which is mached by:
\/
should also be matched by
*\/
and
.*\/

Maybe I will understand the difference in
interpretations as I become more familiar
with Cygwin. Untill then I am stumped.

Thanks,

Clark


--== Sent via Deja.com http://www.deja.com/ ==--
Share what you know. Learn what you don't.

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com



--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: How do I list subdirectories?
@ 1999-08-25 14:23 13mb80000-HallM(DR3132)37x10
  1999-08-31 23:49 ` 13mb80000-HallM(DR3132)37x10
  0 siblings, 1 reply; 28+ messages in thread
From: 13mb80000-HallM(DR3132)37x10 @ 1999-08-25 14:23 UTC (permalink / raw)
  To: cygwin

A minor nit in an otherwise very clear and concise description of
the misunderstandings..

> > It seems that this is a question on pattern matching.
> > It seems to me that a directory which is mached by:
> > \/
> > should also be matched by
> > *\/
> ... if we're using shell patterns (which the grep command isn't).
> In the regexps that grep is using, it'd be appropriate for you to be
> told that your regexp is invalid, because there aren't any characters
> before the Kleen star.
> Remember, too, that the "*/" isn't being fed to grep, too--all of the
> file-names, ending in '/', joined together by spaces, are, and that's
> not going to match.

Actually, I believe that all of the file-names ending in '/' (that is,
all of the valid paths with an element of the current directory followed
by a slash, except for those beginning with a .) will be passed to egrep
as separate arguments.  egrep will interpret the first argument as the
pattern to search for, and the subsequent arguments as files to search for
the pattern in.  If there are two or more paths expanded, (i.e. egrep sees
a pattern and one or more files), egrep will not read standard input at
all and will instead search the "files" for the "pattern".

Depending on whether the OS allows a directory to be opened and read, egrep
may complain that it cannot open the "files", or it may open it and search
for the "pattern", which it probably would not find, but it just might if
the directory looked just right.

....

Well, I did say that it was a minor nit!

marcus hall

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: How do I list subdirectories?
@ 1999-08-25 13:41 13mb80000-HallM(DR3132)37x10
  1999-08-31 23:49 ` 13mb80000-HallM(DR3132)37x10
  0 siblings, 1 reply; 28+ messages in thread
From: 13mb80000-HallM(DR3132)37x10 @ 1999-08-25 13:41 UTC (permalink / raw)
  To: cygwin

> Nice try but 
> ls -F | egrep .*\/ 
> doesn't work.
> I agree that it ought to. I don't understand why it
> doesn't.


For a hint, try the command:
	echo .*\/
and you will see that the shell globs the argument.  Depending on the contents
of the directory, you will get something like ./ ../ as output from the echo.
So, the command:
	ls -F | egrep .*\/
is the same as saying
	ls -F | egrep ./ ../
Which certainly isn't what you want.

Try
	ls -F | egrep '.*\/'

> However Kim Poulsen found a command that does work:
> ls -F | egrep \/
> 
> It seems that this is a question on pattern matching.
> It seems to me that a directory which is mached by:
> \/
> should also be matched by
> *\/
> and 
> .*\/

Egrep works with regular expressions, shell works with glob expressions.
In regular expressions, the * means zero or more of whatever preceeded the
*.  Thus, in the second case, since there was nothing preceeding the *,
it really doesn't make sense as a regular expression.  If you pass that
to egrep (remember to quote it to protect it from the shell) egrep reports
a syntax error.

So, when passed to egrep, the first pattern recognizes a slash (I still
don't understand the need to escape the slash, since it has no particular
meaning to egrep.)  The second pattern is a syntax error, and the third
pattern matches anything (or nothing) and then a slash.

As shell glob expressions, the first pattern doesn't contain any glob
characters and so it would be passed as a slash (the shell does remove
the escape backslash).  The second pattern would match any path that can
be constructed with anything (the *) followed by a slash.  This gives
you all of the directories within the current directory (at least those
that don't start with a ., because the shell doesn't expand * to include
those files).  The third expression would match any path that can be
constructed with a leading ., then anything, then a slash.  So, using
the shell instead of egrep, we can come very close to the desired behavior
with the command:
	echo */ .*/
When the shell processes the arguments, the first argument will be replaced
with all directories that do not begin with a '.' and the second will be
replaced with all directories that do begin with a '.'.  The only problem
here is that if the pattern doesn't match anything, then it will be left
there and not expanded.  So, if you have a basically empty directory, this
will produce
	*/ ./ ../
since the first argument is not expanded (nothing matches it) and the second
matches the current and parent directories.  To eliminate this bother, we
can use ls instead and throw away the error, so the command:
	ls -d */ .*/ 2>/dev/null
should show all the directories within the current directory.

marcus hall

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: How do I list subdirectories?
  1999-08-25 10:04 John Wiersba
@ 1999-08-25 12:07 ` Joshua Rosen
  1999-08-31 23:49   ` Joshua Rosen
  1999-08-31 23:49 ` John Wiersba
  1 sibling, 1 reply; 28+ messages in thread
From: Joshua Rosen @ 1999-08-25 12:07 UTC (permalink / raw)
  To: egcs; +Cc: cygwin

John Wiersba wrote:
> 
> <SNIP>
> 
> > I am wondering why using a backslash anyware in a shell expression
> > escapes all of the asterisks, right now..., but that appears to be
> > something about bash, not Cygwin.
> 
> It doesn't.

Hrm. I think that my having not eaten was making me hallucinate--I'm
no longer seeing the files listed that I was when I used the same
wildcard characters....

-- 
-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GFA/CS/L/M/P/MU/O d(-) s:-- a? C++++$>$ UL P L+ E W+++ N-(!) o? K(--)
w(--)(---) O+++ M-- V? PS+++ PE Y+ PGP-(+++) t 5 X+ R* tv(+) b+ DI+
D---- G+++ e- h! r%--- y+
------END GEEK CODE BLOCK------
rozzin@geekspace.com -- http://i.am/rozzin

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 28+ messages in thread

* RE: How do I list subdirectories?
@ 1999-08-25 10:04 John Wiersba
  1999-08-25 12:07 ` Joshua Rosen
  1999-08-31 23:49 ` John Wiersba
  0 siblings, 2 replies; 28+ messages in thread
From: John Wiersba @ 1999-08-25 10:04 UTC (permalink / raw)
  To: 'Joshua Rosen', cygwin

<SNIP>

> I am wondering why using a backslash anyware in a shell expression
> escapes all of the asterisks, right now..., but that appears to be
> something about bash, not Cygwin.

It doesn't.  Go to any dir with subdirs and try

echo */
echo *\/
echo *\a*/   (assuming some subdir has an "a" in it)
echo *z*/    (assuming no subdir has a "z" in it)

If you have shopt -u nullglob (the default) then a failed pattern is left as
is.

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: How do I list subdirectories?
  1999-08-25  6:10  Clark Sims 
  1999-08-25  7:36 ` Keith Starsmeare
@ 1999-08-25  9:26 ` Joshua Rosen
  1999-08-31 23:49   ` Joshua Rosen
  1999-08-25 18:15 ` Ajit George
  1999-08-31 23:49 `  Clark Sims 
  3 siblings, 1 reply; 28+ messages in thread
From: Joshua Rosen @ 1999-08-25  9:26 UTC (permalink / raw)
  To: cygwin

Clark Sims wrote:
> 
> Nice try but
> ls -F | egrep .*\/
> doesn't work.
> I agree that it ought to. I don't understand why it
> doesn't.

Because the asterisk is neither quoted nor escaped, so it's being
expanded by the shell before it's fed to grep.

Use any of:
	'.*/'
	".*/"
	.\*/

Note that the forward slash doesn't need to be escaped--it's not a
special regexp character.

> However Kim Poulsen found a command that does work:
> ls -F | egrep \/

And this works (with less typing;)), because (e|f|)grep finds an
equivilant substring -anywhere- in the string that you grep from. You
only need the ".*" if you use it like "^.*" ;)

> 
> It seems that this is a question on pattern matching.
> It seems to me that a directory which is mached by:
> \/
> should also be matched by
> *\/
... if we're using shell patterns (which the grep command isn't).
In the regexps that grep is using, it'd be appropriate for you to be
told that your regexp is invalid, because there aren't any characters
before the Kleen star.
Remember, too, that the "*/" isn't being fed to grep, too--all of the
file-names, ending in '/', joined together by spaces, are, and that's
not going to match.

look at the string output by:
	echo */

I am wondering why using a backslash anyware in a shell expression
escapes all of the asterisks, right now..., but that appears to be
something about bash, not Cygwin.

Oh--a fairly good description of standard regexps (and all sorts of
other things) can be found in the Free Online Dictionary of Computing:
http://foldoc.doc.ic.ac.uk/

		-Rozzin.
-- 
-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GFA/CS/L/M/P/MU/O d(-) s:-- a? C++++$>$ UL P L+ E W+++ N-(!) o? K(--)
w(--)(---) O+++ M-- V? PS+++ PE Y+ PGP-(+++) t 5 X+ R* tv(+) b+ DI+
D---- G+++ e- h! r%--- y+
------END GEEK CODE BLOCK------
rozzin@geekspace.com -- http://i.am/rozzin

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 28+ messages in thread

* RE: How do I list subdirectories?
@ 1999-08-25  8:06 John Wiersba
  1999-08-31 23:49 ` John Wiersba
  0 siblings, 1 reply; 28+ messages in thread
From: John Wiersba @ 1999-08-25  8:06 UTC (permalink / raw)
  To: ' Clark Sims ', cygwin

ls -F | grep /$
works.  I'm not sure why you used egrep or *\ in your version.  BTW, ls -F
won't catch directories which start with . (use -A) and it won't catch
symlinks to directories (use -L).

> -----Original Message-----
> From: Clark Sims [ mailto:clarksimsgnu@my-Deja.com ]
> Sent: Wednesday, August 25, 1999 8:13 AM
> To: cygwin@sourceware.cygnus.com
> Subject: How do I list subdirectories?
> 
> 
>  In the FSF version of bash
> ls -F | egrep *\/
> listed all of the subdirectories of the current working
> directory.
> In the Cygwin version the same command produces no
> output.
> 
> How do I list the subdirectories of the current working
> directory?
> 
> Thanks in Advance,
> 
> Clark Sims
> 
> 
> --== Sent via Deja.com http://www.deja.com/ ==--
> Share what you know. Learn what you don't.
> 
> --
> Want to unsubscribe from this list?
> Send a message to cygwin-unsubscribe@sourceware.cygnus.com
> 

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: How do I list subdirectories?
  1999-08-25  6:10  Clark Sims 
@ 1999-08-25  7:36 ` Keith Starsmeare
  1999-08-31 23:49   ` Keith Starsmeare
  1999-08-25  9:26 ` Joshua Rosen
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 28+ messages in thread
From: Keith Starsmeare @ 1999-08-25  7:36 UTC (permalink / raw)
  To: Clark Sims; +Cc: cygwin

> >> How do I list the subdirectories of the current working
> >> directory?

I use:

ls -d `find * -type d -prune -print`

which I alias to lsd - trippy!

Keith

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: How do I list subdirectories?
@ 1999-08-25  6:44 Earnie Boyd
  1999-08-31 23:49 ` Earnie Boyd
  0 siblings, 1 reply; 28+ messages in thread
From: Earnie Boyd @ 1999-08-25  6:44 UTC (permalink / raw)
  To: cygwin users

---  Clark Sims  <clarksimsgnu@my-Deja.com> wrote:
-8<-
> It seems that this is a question on pattern matching.
> It seems to me that a directory which is mached by:
> \/
> should also be matched by
> *\/
> and 
> .*\/
> 
> Maybe I will understand the difference in
> interpretations as I become more familiar
> with Cygwin. Untill then I am stumped.
> 

My guess is that the * is begin interpretted as a globbing wildcard instead of
the regular expression wildcard and you're getting the list of files in the
current directory as the pattern to match.  You can test this by quoting the *.
===
Earnie Boyd < mailto:earnie_boyd@yahoo.com >

Newbies, please visit
< http://www.freeyellow.com/members5/gw32/index.html >

(If you respond to the list, then please don't cc me)
__________________________________________________
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: How do I list subdirectories?
@ 1999-08-25  6:10  Clark Sims 
  1999-08-25  7:36 ` Keith Starsmeare
                   ` (3 more replies)
  0 siblings, 4 replies; 28+ messages in thread
From:  Clark Sims  @ 1999-08-25  6:10 UTC (permalink / raw)
  To: cygwin

 
--

On Wed, 25 Aug 1999 05:25:34   Earnie Boyd wrote:
>---  Clark Sims  <clarksimsgnu@my-Deja.com> wrote:
>>  In the FSF version of bash
>> ls -F | egrep *\/
>> listed all of the subdirectories of the current working
>> directory.
>> In the Cygwin version the same command produces no
>> output.
>> 
>> How do I list the subdirectories of the current working
>> directory?
>> 
>
>Doesn't the egrep need to be `egrep .*\/'?  The period indicates any character,
>the * indicates any number of the preceding character.  Therefore to match what
>you want you need to specify .* to mean any number of any character.
>

Nice try but 
ls -F | egrep .*\/ 
doesn't work.
I agree that it ought to. I don't understand why it
doesn't.

However Kim Poulsen found a command that does work:
ls -F | egrep \/

It seems that this is a question on pattern matching.
It seems to me that a directory which is mached by:
\/
should also be matched by
*\/
and 
.*\/

Maybe I will understand the difference in
interpretations as I become more familiar
with Cygwin. Untill then I am stumped.

Thanks,

Clark


--== Sent via Deja.com http://www.deja.com/ ==--
Share what you know. Learn what you don't.

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: How do I list subdirectories?
  1999-08-25  5:13  Clark Sims 
@ 1999-08-25  5:20 ` Kim Poulsen
  1999-08-31 23:49   ` Kim Poulsen
  1999-08-31 23:49 `  Clark Sims 
  1 sibling, 1 reply; 28+ messages in thread
From: Kim Poulsen @ 1999-08-25  5:20 UTC (permalink / raw)
  To: egcs; +Cc: cygwin

Clark Sims wrote:
>  In the FSF version of bash
> ls -F | egrep *\/
> listed all of the subdirectories of the current working
> directory.
> In the Cygwin version the same command produces no
> output.
> How do I list the subdirectories of the current working
> directory?

ls -lR
or if you only want the subdirs
ls -F |egrep \/

grep'ing for *\/ will search for files ending with '*/' 
which is hopefully none.

-- 
 Kim Poulsen, B.Sc.E.E, System Developer HW
 Ericsson Telebit A/S     Tel: + 45 86 28 81 76
 Fabriksvej 11            Fax: + 45 86 28 81 86
 DK-8260 Viby J           E-mail: info@tbit.dk
 Denmark                  URL: http://www.tbit.dk/

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 28+ messages in thread

* How do I list subdirectories?
@ 1999-08-25  5:13  Clark Sims 
  1999-08-25  5:20 ` Kim Poulsen
  1999-08-31 23:49 `  Clark Sims 
  0 siblings, 2 replies; 28+ messages in thread
From:  Clark Sims  @ 1999-08-25  5:13 UTC (permalink / raw)
  To: cygwin

 In the FSF version of bash
ls -F | egrep *\/
listed all of the subdirectories of the current working
directory.
In the Cygwin version the same command produces no
output.

How do I list the subdirectories of the current working
directory?

Thanks in Advance,

Clark Sims


--== Sent via Deja.com http://www.deja.com/ ==--
Share what you know. Learn what you don't.

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~1999-08-31 23:49 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-08-25  5:24 How do I list subdirectories? Earnie Boyd
1999-08-31 23:49 ` Earnie Boyd
  -- strict thread matches above, loose matches on Subject: below --
1999-08-25 14:23 13mb80000-HallM(DR3132)37x10
1999-08-31 23:49 ` 13mb80000-HallM(DR3132)37x10
1999-08-25 13:41 13mb80000-HallM(DR3132)37x10
1999-08-31 23:49 ` 13mb80000-HallM(DR3132)37x10
1999-08-25 10:04 John Wiersba
1999-08-25 12:07 ` Joshua Rosen
1999-08-31 23:49   ` Joshua Rosen
1999-08-31 23:49 ` John Wiersba
1999-08-25  8:06 John Wiersba
1999-08-31 23:49 ` John Wiersba
1999-08-25  6:44 Earnie Boyd
1999-08-31 23:49 ` Earnie Boyd
1999-08-25  6:10  Clark Sims 
1999-08-25  7:36 ` Keith Starsmeare
1999-08-31 23:49   ` Keith Starsmeare
1999-08-25  9:26 ` Joshua Rosen
1999-08-31 23:49   ` Joshua Rosen
1999-08-25 18:15 ` Ajit George
1999-08-26 12:25   ` Josh Baudhuin
1999-08-31 23:49     ` Josh Baudhuin
1999-08-31 23:49   ` Ajit George
1999-08-31 23:49 `  Clark Sims 
1999-08-25  5:13  Clark Sims 
1999-08-25  5:20 ` Kim Poulsen
1999-08-31 23:49   ` Kim Poulsen
1999-08-31 23:49 `  Clark Sims 

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).