list files but not directory

William Case billlinux at rogers.com
Sat Aug 22 17:00:01 UTC 2009


Hi Patrick;

To continue as a conversation, but not belabour the point.

On Sat, 2009-08-22 at 11:14 -0430, Patrick O'Callaghan wrote:
> On Sat, 2009-08-22 at 03:59 -0400, William Case wrote:
> > Hi Tim;
> > On Sat, 2009-08-22 at 16:58 +0930, Tim wrote:
> > > On Fri, 2009-08-21 at 10:35 -0400, William Case wrote:
> > > > It seems illogical, that 'ls' wouldn't have a flag that just shows
> > > > files when it has a flag for directories.
> > > 
> > > Though that flag "ls -d" has a completely different purpose (show
> > > directory names, rather than go into them and list their contents).
> > > 
> > True.  But whatever its purpose, it does give me a list of directory
> > names.
> 
> In fact it lists *all* its arguments as usual (the default being ".", as
> always), except that those which are directories are not listed
> recursively. It doesn't "give a list of directory names", unless that's
> what the arguments happen to be.
> 

Yea, I know.  But by reading the ls man page and a couple of experiments
I was able to get ls -d ./* to print a list of the directories to stout.

> There are no flags to ls which mean "ignore any arguments which belong
> to this class of object".
> 
And isn't that a shame.

> > All that I am saying is that it would be handy to have a simple util
> > that listed file names.
> 
> If you want to filter out directories, use grep, as several people have
> pointed out. That's the Unix Way (tm).

But why make people use grep ( a whole to learning curve; particularly
if you are new) when I simple option could do it for you.

> 
> >  I suggest 'ls' because it is probably the most
> > used and first learned listing utility and therefore would be the place
> > to have it.  It would be useful to beginners (particularly those who do
> > not yet have any idea what a regexp is) and for script writing or piping
> > to sed, awk, grep or a new file (or for appending).
> 
> Said beginners need to learn that *directories are files* (and devices
> are files, named pipes are files, etc.). This is an important concept
> which should not be hidden.

I don't limit my remarks to "Said beginners", I think the option would
be useful to practised Linux users too.  But remembering the
befuddlement, confusion and fluster I felt as a new user did bring the
issue back to mind.

Nor do I think it is the place of any Linux distribution to decide when
and what users should learn.  To me, that's M$ type of thinking.
Perhaps some users can't remember as far back as when they first started
using Linux or Unix, or perhaps they have always had an intuitive grasp
of how computers work.

Or, maybe, there is just the natural old pro desire to force an
unnecessarily onerous initiation period on beginners. 

In lieu of providing an additional option to 'ls' coreutils could
provide an 'lsf' command that would print the simple information that is
desired.  I didn't jump into this thread because it was something I
REALLY NEEDED, but because I thought it might be useful to others.

Such an lsf command should be a kind of a command line alternative to
gui file browsers like nautilus.

-- 
Regards Bill
Fedora 11, Gnome 2.26.3
Evo.2.26.3, Emacs 23.1.1




More information about the fedora-list mailing list