Mail Archives: cygwin/2002/11/14/13:02:10
Hi, Randy,
Umm, no, we're not going for convolutedness here, we're trying to figure
out how to do an equivalent of globbing without actually expanding the
whole thing on the command line...
You're right about the "./" being prepended to the output of find, and so
I agree with the "sed" suggestion (except that I'd modify it to "sed
's@\./@@'" to avoid an extra backslash). I'll have to disagree with the
-d, however, since the original command ("ls *") *will* list the contents
of each subdirectory (as opposed to the plain "ls", which won't).
Igor
P.S. Geez, 25 years? You beat me by 2.5x... :-)
On Thu, 14 Nov 2002, Randall R Schulz wrote:
> Hi, Igor,
>
> Well, if we're going to play "what's the most convoluted way you can think
> of to do something with a much simpler equivalent," then I should point out
> that you need to modify your suggestion thusly:
>
> find . -maxdepth 1 \( -name .\* -o -print \) |sed -e 's/^\.\///' |xargs ls -d
>
> First, unless you give the "-d" option to "ls," you'll get a listing of the
> contents of any directories whose names are output by "find." (Or is that
> what the original user wanted? Somehow I don't think so.)
>
> Second, the names "find" prints (and which "ls" will subsequently reproduce
> in its output) will have "./" as a prefix, so the "sed" command is needed
> to remove them. This would also be true if you used the default starting
> directory for "find" (i.e., if you omit the "." argument).
>
> Personally, plain old "ls" works well for me.
>
> God!... Is this all my 25 years of using Unix is worth?
>
> Randall Schulz
> Mountain View, CA USA
>
>
> At 09:29 2002-11-14, Igor Pechtchanski wrote:
> >Well, if you really want something equivalent to 'ls *', you'd need to do
> >something like
> >
> >find . -maxdepth 1 \( -name .\* -o -print \) | xargs ls
> >
> >The "-maxdepth 1" is to not descend recursively into directories, and the
> >"-name .\*" is to avoid listing hidden files/directories (which would not
> >be matched by the '*' glob). The "-type f" is actually wrong, as '*' will
> >match directories as well.
> >
> >Also beware that ls may be an alias, and xargs will run the actual
> >executable in the path...
> > Igor
--
http://cs.nyu.edu/~pechtcha/
|\ _,,,---,,_ pechtcha AT cs DOT nyu DOT edu
ZZZzz /,`.-'`' -. ;-;;,_ igor AT watson DOT ibm DOT com
|,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski
'---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow!
"Water molecules expand as they grow warmer" (C) Popular Science, Oct'02, p.51
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -