[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#21218: ls -d
From: |
Assaf Gordon |
Subject: |
bug#21218: ls -d |
Date: |
Mon, 10 Aug 2015 23:05:42 -0400 |
Hello Eddie,
> On Aug 10, 2015, at 19:24, Sneeh, Eddie <address@hidden> wrote:
> I guess what it boils down to is "-d" is a confusing choice of option for
> what it really does. "ls --directory" has little to do with directories,
> (and adding the word "themselves" to the definition doesn't really remove
> much ambiguity), -d lists everything at one level, non-directories included!
I can see why this might be confusing.
If there are suggestions for improved wording (while still being concise and
clear), then it might be possible to change the help/man pages.
However, regarding the functionality of '-d' - that I'm quite certain will not
change.
It is a long-established behavior of 'ls', one that has been standard on many
operating systems and for many years (possibly decades? I'm too new to know for
sure).
But perhaps look at it from another perspective:
you've mentioned two requests of affecting ls's output:
> what I suggested is more intuitive:
> ls -d (list directories)
> ls -f (list files)
> ls -l (list links)
and:
> The current -d should have been something like: --1level or --dont_descend or
> the like.
When in fact, 'find' has exactly these options!
If you think of 'ls' as:
list files, catering to the most common use-cases,
and think of 'find' as:
list files with maximum flexibility of filters and conditions
then the distinction between them becomes clearer.
With find you can already performs your requested options:
find -type f (list regular files)
find -type l (list symbolic links)
find -type d (list directories)
find -maxdepth 1 (don't descend into sub-directories)
and 'find' allows you even more, because you can combine these conditions in as
flexible way as you'd like.
for example, to list all directories up to 3 levels down, which start with 'b',
owned by me and are writable:
find . -maxdepth 3 -name "b*" -user assaf -writable
or, list all regular files in the current directory that have been accessed in
the last 24 hours, and print their name and size:
find . -maxdepth 1 -type f -atime 1 -printf "%s %f\n"
My point is, the moment you need more than basic listing of files,
you should switch from 'ls' to 'find'.
This way we can avoid adding more functionality to 'ls' because it already
exists in 'find'.
regards,
- assaf
- bug#21218: ls -d, Sneeh, Eddie, 2015/08/07
- bug#21218: ls -d, Eric Blake, 2015/08/07
- bug#21218: ls -d, Rainer M. Canavan, 2015/08/08
- bug#21218: ls -d, Sneeh, Eddie, 2015/08/10
- bug#21218: ls -d, Assaf Gordon, 2015/08/10
- bug#21218: ls -d, Sneeh, Eddie, 2015/08/10
- bug#21218: ls -d,
Assaf Gordon <=
- bug#21218: ls -d, Sneeh, Eddie, 2015/08/10
- bug#21218: ls -d, Bob Proulx, 2015/08/12
- bug#21218: ls -d, Eric Blake, 2015/08/10
- bug#21218: ls -d, Sneeh, Eddie, 2015/08/10
bug#21218: ls -d, Bob Proulx, 2015/08/09