Re: list files but not directory

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

 



Marko Vojinovic wrote:
> 
> 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. 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." ;-)
> 
And to carry this one step farther, you can create aliases or
function to do things you require often. For example, you could use
something like this:

function lsp() { ls $@ && less }

so that you could run lsd instead of running "ls | less".

Mikkel
-- 

  Do not meddle in the affairs of dragons,
for thou art crunchy and taste good with Ketchup!

Attachment: signature.asc
Description: OpenPGP digital signature

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