Re: list files but not directory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Marko;

On Sat, 2009-08-22 at 21:05 +0100, Marko Vojinovic wrote:
> > On Sat, Aug 22, 2009 at 03:59:30 -0400,
> >   William Case <billlinux@xxxxxxxxxx> wrote:
> > > All that I am saying is that it would be handy to have a simple util
> > > that listed file names.  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).
> 
> There is just one thing that baffles me here --- isn't a directory also a file? 
> Given that, what you ask for is not an option to list only files, it is an 
> option to list everything except directories. In other words, you are asking 
> for an option that says "list the directory contents, but omit certain 
> things".
> 
> The more appropriate way to do this is to use some form of filtering. Such a 
> thing does not naturally fit into a list of options of ls, IMHO. What you 
> actually do is perform two operations here --- list the contents, and then 
> filter it to display only some subset. Two operations should be done using two 
> commands, the Unix Way. And the filtering approach gives you more flexibility 
> what file types to filter out. For example, is /dev/sda a file or a directory? 
> How would this hypothetical ls option behave in this case? List it or not?
> 
> There are not *just directories and files* on the system. There are
> *just files*. And these files might be regular files, directories, devices, 
> stdin/stdout, and who knows what else. You are proposing to add a single 
> option to ls in order to filter out one of these types. Why only this one type? 
> Put a whole bunch of options in ls which could list only regular files, or only 
> character devices, or only hidden directories or... Or better yet, don't put 
> any of that crap into ls, but pipe the ls output and filter it using a more 
> appropriate tool.
> 
> The completely analogous situation is with paging the output of ls. When I 
> first used ls on a directory with lots of files, the natural idea for me was to 
> look into its man page to find some option that would split the output into 
> several screens and display them one by one. I failed to find such an option. 
> After some digging, I found that this is done via a pipe to less:
> 
> ls | less
> 
> And then after some learning I understood that this is actually the better way 
> to do it (more powerful, more flexible, more clean, more useful). The same 
> situation is here with listing only non-directories. 
> 
> The main problem is not lack of functionality, but that Windows-converts have 
> a frame of mind that makes a distinction between "directory" and "file" 
> concepts, and believe these concepts are fundamentally different and non-
> overlapping. 

That is exactly where I was coming from and believe that that defines
the problem the original poster had.

> This is a Bad Idea, and it seems more appropriate to educate 
> users than to add options to ls which make it do things it is not designed 
> for.
> 
> Just remember: "Do one simple thing and do i well." ;-)

Marko, you have given the best explanation and counter argument yet to
this post.

However, I could tell you several (delightful) horror stories of hours
and hours I wasted when I first came to Linux from Windows.  I bet there
are others who have had an equalling trying experience.  Don't get me
wrong, Linux is by far the best operating system.  But I still find
myself from time to time trying to solve problems by using 'MicroSoft
Intuition'.  That usually means looking for a complex answer when, in
Linux, a simple answer will do.

In any case, I always keep my eye open for the newbies for whom
'intuition' is not working.  They often get dismissed as if they should
know better.

I guess that all I was proposing was giving people some transitional
tools.  To me, a regular file will always be a file different from the
others.

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

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux